Why it matters

Time in distributed systems is subtle. Lamport clocks provide safe ordering; understanding matters for correctness.

Advertisement

The architecture

Rules: increment on local event; when sending, include timestamp; when receiving, set clock = max(local, received) + 1.

Produces total order consistent with causality.

Lamport clock rulesLocal eventincrementSend messageattach timestampReceive messagemax + 1If A happened before B, timestamp(A) < timestamp(B); converse not guaranteed
Clock update rules.
Advertisement

How it works end to end

Total order: tiebreak by node ID for identical timestamps.

Limitations: can't detect concurrent events (both happen 'at same time').

Vector clocks fix concurrent detection at cost of size.