A logical clock assigns timestamps or ordering information to events without measuring physical time. It orders events through the happened-before relationship, while physical clocks measure duration and can suffer drift, skew, and synchronization problems. section 2.2.4 section 2.2.5
A Lamport clock provides a precise mental model:
- Each component maintains a counter, increments it at every internal or external step, and tags events with the current value. section 2.2.4
- When a message arrives, the receiver advances its counter to at least the maximum of its value and the received timestamp plus one. section 2.2.4
- This gives causally related events strictly increasing logical-time values, but timestamps may not be comparable across independent Kafka partitions. section 2.2.4
Partition offsets as logical time
Kafka assigns each message an offset within its partition. An earlier message has a smaller offset, allowing consumers to track progress; offsets from different partitions cannot be compared. etcd similarly increments a per-key sequence number to support compare-and-swap operations. section 2.2.4
Figure 2.18 Lamport clocks
Use the Lamport-clock figure to visualize counter advancement across components and message delivery. section 2.2.4

