Time, Clocks & Ordering
Studies in this cluster, in series order. Each one keeps its own URL.
Distributed systems
Raft consensus, replication, consistent hashing, saga-style distributed transactions, two-phase commit, and conflict-free replicated data types.
Time, Clocks & Ordering
6 studies- 1.Time, Clocks & Ordering in Distributed Systems - Physical Clocks, Lamport, Vector Clocks, HLC & TrueTimeInterview hub: why no machine knows the real time; wall vs monotonic; the ladder from NTP wall clocks to Lamport, vector clocks, HLC and TrueTime with a decision flow; runnable LWW-on-skewed-clocks data loss vs Lamport vs vector clocks; comparison table incl. timestamp oracles; Cloudflare 2017 leap second, Spanner, CockroachDB, Dynamo, Snowflake/UUIDv7 anchors.
- 2.Physical Clocks - NTP/PTP, Drift & Skew, Wall vs Monotonic Time & Leap SecondsHow clocks are kept in sync: oscillator drift (ppm), NTP four-timestamp offset/delay math and the delay/2 error bound (runnable), slew vs step, NTP vs PTP vs cloud time (ClockBound); wall vs monotonic APIs per language; runnable lease bug under an NTP step; leap seconds step vs smear; failure catalog (LWW, leases, TTL/JWT, negative durations).
- 3.Lamport Clocks - Happens-Before, Logical Timestamps & Total OrderHappens-before precisely; Lamport clock rules and total order with (ts, pid) tie-break (runnable); runnable proof that the clock condition holds but L(a)<L(b) does not imply causality; Lamport vs wall vs vector vs HLC vs consensus log index; Raft terms and fencing tokens as logical clocks; pitfalls (tie-break, persistence).
- 4.Vector Clocks vs Version Vectors - Detecting Concurrent Writes, Siblings & Dotted Version VectorsVector clock rules and four-way compare; runnable Dynamo-style sibling store with context and merge; vector clocks vs version vectors vs client-id vclocks vs dotted version vectors; runnable LWW vs per-server VV (lost write) vs DVV (siblings); size growth and pruning; LWW vs siblings vs CRDTs vs consensus; Dynamo, Riak 2.0, Cassandra.
- 5.Hybrid Logical Clocks & TrueTime - Commit Wait, Uncertainty Intervals & External ConsistencyHLC algorithm (l, c) with skewed nodes and a max-offset guard (runnable); CockroachDB max-offset self-termination, MongoDB cluster time, YugabyteDB; TrueTime intervals and commit wait (runnable) plus CockroachDB-style uncertainty restarts; external consistency vs serializability vs SI; TrueTime vs HLC vs timestamp oracle vs single leader.
- 6.Distributed ID Generation - Snowflake, UUIDv4 vs UUIDv7, ULID, KSUID & SequencesID schemes compared (sequences, hi-lo, Flickr ticket servers, Snowflake, Instagram, UUIDv4, UUIDv7/RFC 9562, ULID, KSUID); runnable Snowflake with sequence overflow and clock-rollback handling; runnable UUIDv7 with monotonic counter plus B-tree right-edge locality vs UUIDv4; ordering vs locality vs coordination; hot-partition twist; JS 2^53 pitfall.