← Lessons

quiz vs the machine

Platinum1780

System Design

Clock Synchronization with NTP

How machines align their clocks and why you still cannot fully trust time.

5 min read · advanced · beat Platinum to climb

Why clocks drift

Each machine has its own oscillator that runs slightly fast or slow, so clocks drift apart over time. Distributed systems that compare timestamps across machines need them roughly aligned.

How NTP works

The Network Time Protocol syncs a machine to time servers arranged in tiers called strata.

  • The client measures round trip delay to a server and estimates one way latency as half of it.
  • It uses that estimate to correct its offset from the server.
  • It slews the clock gradually rather than jumping, to avoid time going backward.

Why you still cannot trust it

Even synced, clocks have an uncertainty window of several milliseconds. Comparing two timestamps across machines can give the wrong order if they fall within that window. This is why systems avoid relying on wall clocks for ordering and prefer logical clocks or bounded uncertainty like TrueTime.

Key idea

NTP narrows clock drift using round trip estimates and gradual slewing, but a residual uncertainty window means physical timestamps cannot be trusted for precise cross machine ordering.

Check yourself

Answer to earn rating on the learn ladder.

1. Why does NTP slew the clock instead of jumping it?

2. Why can you not fully trust NTP synced timestamps for ordering events across machines?

3. What does NTP use to estimate one way latency to a server?