Distributed Time
The pattern: there is no global clock in distributed systems. Wall clocks drift, NTP can jump, leap seconds exist. Logical clocks (Lamport, vector) capture happens-before without requiring synchronized time. Hybrid logical clocks combine wall + logical for the best of both.
The trade-off: wall-clock simplicity vs. correctness under skew. Wall clocks are convenient and human-readable but lie. Logical clocks are correct but harder to reason about. Spanner’s TrueTime uses atomic clocks + GPS to bound wall-clock uncertainty — a wildly expensive solution that buys you global serializable transactions. Most systems pick somewhere in between, accepting bounded inconsistency.
[Deepen Year 2 Phase 8 — implement a Lamport clock in 15 lines of Go; reason about happens-before for concurrent events.]
Related patterns
- Consensus — Raft terms and Paxos ballots are logical clocks dressed up as protocol state.
- CAP and PACELC — TrueTime is the trick that buys Spanner its PC/EC posture without paying full coordination per write.
- Eventual consistency — “last-write-wins” is only well-defined relative to some clock; usually the wrong one.
- CRDTs — vector clocks and version vectors are the merge metadata.
- Write-ahead logging — LSN / log offsets are the practical logical clock for a single replica chain.
First touched in Year 2 Phase 8 via DDIA Ch. 8; the Lamport-clock-in-Go exercise is what makes happens-before stop being a vibe.