What a vector clock holds
A vector clock is an array with one counter per node. Each process increments its own slot on every event and attaches the whole vector to messages. On receive, a node takes the element wise maximum of its vector and the incoming one, then increments its own slot.
Comparing two vectors
Given vectors V and W:
- V happened before W if every element of V is less than or equal to the matching element of W and at least one is strictly less.
- W happened before V by the symmetric rule.
- If neither dominates, the events are concurrent, which signals a potential conflict.
This is the key advantage over a single scalar Lamport clock: vector clocks can detect concurrency, not just impose a total order.
Cost
The vector grows with the number of nodes, so storage and message overhead are O of n. Systems with many short lived nodes use techniques like dotted version vectors to bound this.
Key idea
Vector clocks compare element wise to classify two events as ordered or concurrent, detecting conflicts that a scalar clock cannot.