Skip to content
StackDecode
System Design
6. Distributed Systems FundamentalsAnimated

Logical Clocks

Counters that order events without real time.

The idea

Instead of time, they capture the happens-before relation using counters.

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. 1Each process keeps a counter
  2. 2Increment on events
  3. 3Send it with messages
  4. 4Receivers merge it

Where it is used

Ordering events.

Watch out for

They order events but do not give real time.

Related