The problem with clocks
Every computer has a quartz clock that drifts, gaining or losing time over hours. Across a cluster, clocks disagree by milliseconds or more. The Network Time Protocol keeps them roughly aligned by querying time servers.
How NTP works
A client asks a server for the time and measures the round trip. By recording the send and receive timestamps on both ends, it estimates network delay and corrects its own clock for the one way latency.
- Servers form a hierarchy of strata rooted at atomic clocks.
- The client adjusts gradually rather than jumping, to avoid time going backward.
Two kinds of clock
- A time of day clock can jump forward or backward when NTP corrects it, so it is unsafe for measuring durations.
- A monotonic clock only moves forward and is the right choice for timing intervals.
Why you still cannot trust it
Even synchronized clocks have uncertainty. Using a timestamp to order events across machines can be wrong if the gap is smaller than the error. This is why logical clocks and explicit ordering exist, and why systems like Spanner expose a clock uncertainty bound directly.
Key idea
NTP aligns drifting clocks against time servers but residual uncertainty means timestamps cannot safely order events across machines.