liveBook · Manning

Logical time

As explained in Think Distributed Systems

Logical time is a system-defined ordering measure for events that does not necessarily correspond to elapsed physical time.

Logical time is a system-defined ordering measure for events, not a measure of elapsed physical time. It helps reason about what happened before what in a distributed system, especially when message delays make physical timing inconclusive. section 2.0 section 2.2.4

The happened-before relationship provides the mental model: events on one component follow one another; sending a message happens before receiving it; and these relationships are transitive. Events without a happened-before relationship are concurrent. Logical clocks assign timestamps that preserve causally related order, but they do not turn concurrent events into physically ordered events. section 2.2.1 section 2.2.4

Common logical-time representations include:

  • Lamport clocks: per-component counters incremented on steps; receivers update their counters using the maximum of local and received time, plus one. section 2.2.4
  • Kafka offsets: positions order messages within one partition, but offsets cannot be compared across partitions. section 2.2.4
  • etcd sequence numbers: per-key increments support operations such as compare-and-swap. section 2.2.4
Figure 2.18 Lamport clocks
A diagram of a number and a number

AI-generated content may be incorrect.

Trace how Lamport-clock values advance across components and messages. section 2.2.4

How Think Distributed Systems covers it

How deep it goes
Explains happened-before causality, Lamport-clock updates, and partition-local timestamps, while stopping short of implementation-heavy treatment.
Examples
Uses Lamport-clock message exchange, Kafka partition offsets, and etcd per-key sequence numbers as concrete representations.
What it assumes
Assumes basic distributed-system components and messages, while building the happened-before model from intra- and intercomponent events.
What you can do after
Evaluate causal ordering and recognize when timestamps provide only partition-local or causality-preserving order.
How it connects
Connects logical clocks with happened-before relationships, causality, concurrency, physical time, Kafka offsets, and etcd sequence numbers.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Think Distributed Systems. The section links point to the parts of the book it draws on.