Vector Clocks
Compare distributed events by causal ancestry instead of assuming one global timeline.
Free theory articleCompare distributed events by causal ancestry instead of assuming one global timeline.
Concept & interpretation
Vector clocks are used to compare distributed events by causal ancestry instead of assuming one global timeline. In a distributed system, it is difficult to maintain a perfectly synchronized physical clock. Vector clocks provide a way to establish a partial ordering of events in the system by tracking causal dependencies.
Experiment
Observe the behavior of vector clocks in different scenarios:
- Select the Chain scenario. Click Finish to reveal all events. Observe that Event 4 (recv a by P1) happens after Event 2 (send a by P0) because its vector clock
[2, 1, 0]is strictly greater than[2, 0, 0]. - Select the Concurrent scenario. Click Finish. Compare Event 3 (send a by P0) and Event 4 (send b by P1). Their vector clocks are
[2, 0, 0]and[0, 2, 0]. Since neither is strictly greater than the other, they are Concurrent. - Try the Fork join scenario and use the Step button to see how the vector clocks are updated event by event. Compare Event 1 and Event 6 to see causality.