Skip to content
StackDecode
System Design
6. Distributed Systems FundamentalsAnimated

Lamport Timestamps

A single counter that respects causality.

The idea

Increment on every event; on receive, take the max of local and message time, then add one.

Watch it work

Press play, pause, or step through. Some animations have settings you can change.

ABC1

Process A a local event: increment its own counter. Timestamp 1.

event:
1
1/9

Lamport timestamps respect cause and effect, but cannot detect concurrency.

Step by step

  1. 1Local event: add one
  2. 2Send: attach the counter
  3. 3Receive: max then add one
  4. 4Order by timestamp

Where it is used

Total ordering of events.

Watch out for

Cannot tell if events are concurrent.

Related