Vector clocks and logical time
In short: In distributed systems clocks disagree. Logical clocks (Lamport) and vector clocks order events by cause and effect instead of wall-clock time.
In more detail: A Lamport clock is a counter incremented on every event and every received message. It guarantees: if A happened before B, time(A) < time(B). The converse does not hold. Vector clocks keep a counter per node and detect true concurrency.
In Depth
- Happened-before (→): Partial order: same process, or send → receive.
- Lamport: On receipt
t = max(local, received) + 1. - Vector clock: Comparing two vectors shows “before”, “after” or “concurrent (conflict)”.
- Wall-clock problems: Clock drift, NTP jumps, leap seconds.
- Hybrid logical clocks: Mix physical and logical time (for example CockroachDB).
- Use: Conflict detection in replication, versioning.
See also: CRDTs: conflict-free replicated data types, Replication: leader and follower