Many software systems that depend on careful sequencing of events rely on a
stable, consistent system clock, using system logs with timestamps to ensure
time synchronization and debug issues as they occur. To help keep system clocks
in sync, Compute Engine virtual machine (VM) instances are preconfigured to
use network time protocol (NTP), a bundled solution of time synchronization
hardware and software. If ensuring accurate time synchronization and monitoring
the accuracy of your time synchronization are important for your goals, you can
configure accurate time instead of NTP, to sync your VM's clock with the host
clock by using chrony and ptp_kvm. This configuration is designed to achieve
accuracy within 1 ms for supported setups.
Supported machine types
The following machine types support accurate time:
Supported operating systems
The following operating systems (OSes) support accurate time:
| OS | Versions | Images | 
|---|---|---|
| CentOS Stream | 9 | centos-stream-9 | 
| Container-Optimized OS | COS 105 LTS, COS 109 LTS, COS 113 LTS, COS 117 LTS | cos-105-lts, cos-109-lts, cos-113-lts, cos-117-lts | 
| Debian | 11 (Bullseye), 12 (Bookworm) | debian-11, debian-12 | 
| Fedora Cloud | 39 | fedora-cloud-39 | 
| RHEL | 8, 9 | rhel-8-4-sap-ha, rhel-8-6-sap-ha, rhel-8-8-sap-ha, rhel-8-10-sap-ha, rhel-9, rhel-9-0-sap-ha, rhel-9-2-sap-ha, rhel-9-4-sap-ha | 
| Rocky Linux | 8, 9 | rocky-linux-8, rocky-linux-8-optimized-gcp, rocky-linux-9-optimized-gcp, rocky-linux-9-optimized-gcp | 
| SLES | 15 | sles-15, sles-15-sp2-byos, sles-15-sp2-sap, sles-15-sp3-byos, sles-15-sp3-sap, sles-15-sp4-byos, sles-15-sp4-sap, sles-15-sp5-byos, sles-15-sp5-sap | 
| Ubuntu | 22.04 LTS (Jammy Jellyfish), 24.04 LTS (Noble Numbat) | ubuntu-2204-lts, ubuntu-2404-lts-amd64 | 
| Ubuntu Pro | 2004 | ubuntu-pro-2004-lts, ubuntu-pro-2004-lts-amd64 | 
Supported zones
The following zones support accurate time:
| Zone | Location | 
|---|---|
europe-west1-b | 
St. Ghislain, Belgium, Europe | 
europe-west1-c | 
St. Ghislain, Belgium, Europe | 
europe-west2-b | 
London, England, Europe | 
europe-west3-a | 
Frankfurt, Germany, Europe | 
us-central1-a | 
Council Bluffs, Iowa, North America | 
us-central1-b | 
Council Bluffs, Iowa, North America | 
us-central1-c | 
Council Bluffs, Iowa, North America | 
us-central1-f | 
Council Bluffs, Iowa, North America | 
us-east1-b
 | 
Moncks Corner, South Carolina, North America | 
us-east1-c
 | 
Moncks Corner, South Carolina, North America | 
us-east4-c | 
Ashburn, Virginia, North America | 
us-east5-a | 
Columbus, Ohio, North America | 
us-south1-a | 
Dallas, Texas, North America | 
us-west1-b | 
The Dalles, Oregon, North America | 
us-west2-a
 | 
Los Angeles, California, North America | 
us-west3-a | 
Salt Lake City, Utah, North America | 
Configure accurate time synchronization
To configure accurate time synchronization for your project's VMs, complete the following tasks for each VM:
- Configure 
chronyto useptp-kvmas its time source. - Configure Google Cloud Ops Agent for data collection and analysis.
 
After you've completed both tasks, accurate time synchronization is set up for the VMs in your project.
For a sample script that creates a VM and completes both tasks to configure accurate time synchronization, see the VM creation script in GitHub.
Configure chrony to use ptp-kvm
To configure chrony to use ptp-kvm as its time source, run the following
script inside each of your Google Cloud project's VMs:
Configure Google Cloud Ops Agent on your VM
To configure Google Cloud Ops Agent for data collection and analysis, run the following script inside each of your Google Cloud project's VMs:
Configure time synchronization monitoring
To configure time synchronization monitoring for your Google Cloud project's VMs, run the logging and dashboard setup script for your Google Cloud project. This script helps you to complete the following tasks for your Google Cloud project:
- It sets appropriate permissions on the service account associated with your VM's Google Cloud project.
 - It creates a log-based metric that 
chronyuses to ensure accuracy between the clocks on the VM and its host server. - It creates a dashboard measuring the VM clock's traceability to UTC by
combining the following metrics:
- The VM host clock's accuracy to UTC.
 - The 
chronymetrics measuring the VM clock's accuracy to its host's clock. 
 
To accomplish the preceding tasks, run the following script:
After the script completes running, use the dashboard it created to view clock accuracy data for your project's VMs.
What's next
- For complete sample code for setting up accurate time, including Google Kubernetes Engine samples, visit the example repository.
 - Review the available options for configuring your VM's time synchronization.