Clocks lie; causality is what you can trust

Time & Ordering

8 lessons. Every one names the guarantee it claims, what a node can know, and how it fails.

Two Timestamps Are Not an Ordering▶ lab

Machine A logs an event at 12:00:01. Machine B logs one at 12:00:03. Which happened first? You cannot tell, and no amount of clock synchronisation makes the comparison sound. A wall-clock timestamp is a reading of a local oscillator, not a position in a shared timeline.

Q · Two machines timestamped two events. Can I use those timestamps to order them?

Clock Skew: The Gap You Cannot Measure From Inside▶ lab

Skew is the difference between two clocks at the same instant. It is small most of the time, unbounded some of the time, and — the part that matters — invisible to the machines involved. A node cannot detect that it is the fast one.

Q · How far apart can two clocks in my fleet be, and what breaks at that distance?

Never Measure a Duration With the Wall Clock▶ lab

Two clocks live in every machine and they answer different questions. The wall clock says what date it is and may jump; the monotonic clock only counts forward and has no idea what date it is. Using the wrong one is a real, shipped bug that surfaces during NTP steps and leap seconds.

Q · Which clock do I read to measure how long something took?

Happens-Before: The Only Ordering You Actually Have▶ lab

If clocks cannot order events across machines, something must. Lamport's happens-before relation orders exactly the pairs of events that could have influenced each other — and deliberately leaves everything else unordered. It is a partial order, and that is the point, not a limitation.

Q · If I cannot use clocks, what does it even mean for one event to come before another?

Lamport Clocks: Consistent With Causality, Blind to Concurrency▶ lab

A single integer per node, incremented on every event and carried on every message, produces a numbering consistent with causality. The implication runs one way only, and almost every description of Lamport clocks gets that backwards.

Q · Can one counter per node give me a usable ordering without any clock?

Vector Clocks: Buying Concurrency Detection at O(N)▶ lab

Replace the single integer with one counter per node and compare component-wise. Now "neither is greater" is representable, which means concurrency becomes detectable — and conflicts become visible instead of silently resolved. The bill arrives as metadata that scales with the number of writers.

Q · How do I tell whether two versions conflict, rather than one superseding the other?

Four Orderings, Four Prices▶ lab

None, FIFO, causal, total. Each is strictly stronger than the last, each rules out anomalies the last permitted, and each costs more coordination — with the last one costing consensus. Choosing an ordering model is choosing how much availability you are willing to spend.

Q · How much ordering does my system actually need, and what does each level cost?

Total Order Broadcast Is Consensus Wearing a Different Hat▶ lab

Delivering the same messages in the same order to every node sounds like a messaging feature. It is not: it is exactly as hard as consensus, and each can be built from the other in a few lines. That equivalence is the reason total ordering is expensive, and it is not going to get cheaper.

Q · Why does making every node see the same order cost so much more than making them see a causally correct order?