Skip to content

Clock skew and drift

Category: Distributed systems · Status: stub

One line: Skew is how far apart two machines' clocks are at one moment, drift how fast they move apart — the reason timestamps from different machines cannot reliably order events.

Also called: clock drift, clock synchronization, NTP, PTP, TrueTime.

How it connects

flowchart LR
  n_clock_skew["Clock skew and drift"]
  n_logical_clocks["Logical clocks"]
  n_clock_skew ---|or| n_logical_clocks
  classDef center stroke-width:3px
  class n_clock_skew center
  classDef outside stroke-dasharray: 4 3
  class n_logical_clocks outside

In each language

Rust Instant is monotonic; SystemTime is not, and is the one for communicating with other processes
Go time.Now returns both a wall-clock and a monotonic clock reading ↗, and the monotonic reading has no meaning outside the current process
C++ std::chrono::steady_clock is monotonic: its time points cannot decrease as physical time moves forward
Java System.nanoTime measures elapsed time only and is not related to wall-clock time
Python time.monotonic cannot go backwards and is not affected by system clock updates
Erlang and Elixir the runtime keeps Erlang monotonic time apart from system time, with time warp modes ↗ for when system time changes
The operating system CLOCK_REALTIME jumps when the system time is changed; CLOCK_MONOTONIC cannot be set

Where to read more