Wall clocks are unreliable across machines. Logical clocks (vectors of counters) track causality precisely. Foundation of many distributed algorithms.
The vector
Each node has counter for every node in cluster. Increment own on event. Send full vector with messages. Update by max on receive.
The vector
Each node has counter for every node in cluster. Increment own on event. Send full vector with messages. Update by max on receive.
Causal comparison
V1 < V2 if V1[i] ≤ V2[i] for all i AND V1 ≠ V2. Means V2 causally happened after V1.
Concurrent detection
Not V1 ≤ V2 AND not V2 ≤ V1 → V1 || V2 (concurrent). Two clients wrote without seeing each other. Conflict.
Size grows with cluster
Vector size = # of nodes. 100-node cluster = 100 ints per version. Alternatives: hybrid logical clocks (HLC) bound size.
Used by
Dynamo, Riak, Cassandra (via timestamps + tie-breakers). Anywhere you need conflict resolution without global order.