In a distributed system, physical "wall clocks" cannot be perfectly synchronized. Network delay and hardware variability mean that two nodes may disagree on which of two events happened first. To solve this, distributed systems use Logical Clocks to capture the Happens-Before relationship (\rightarrow).
Introduced by Leslie Lamport in 1978, the Lamport Clock is a simple monotonic counter maintained by each process.
If a \rightarrow b, then C(a) < C(b). However, the reverse is not true: if C(a) < C(b), we cannot conclude that a caused b. They might be concurrent events that just happened to receive those numbers.
Vector Clocks extend Lamport clocks to provide a full causal history. Instead of a single number, each node maintains a vector (an array) of counters, one for every node in the system.
A cluster of N nodes maintains a vector V[1..N].
Vector clocks allow us to determine if two events are:
| Feature | Lamport Clock | Vector Clock |
|---|---|---|
| Size | O(1) (Scales perfectly) | O(N) (Grows with node count) |
| Causality | No (Partial ordering only) | Yes (Identifies concurrency) |
| Primary Use | Total ordering of events. | Conflict resolution (e.g., Dynamo). |
In 2026, systems like Riak use an optimized version called Dotted Version Vectors. DVVs prevent "sibling explosion" by distinguishing between the causal past and the current event (the "dot"). This allows for more precise conflict resolution with less metadata overhead than classic vector clocks.