Last Minute Notes
  • Github
  • Docs
  • Learn
    @sayanstwt
Lessons
0/37 done
  • CAP & PACELC
  • Consistency Models
  • Time & Ordering
  • Consensus with Raft
  • Locks, Leases & Fencing
  • Isolation Levels & Anomalies
  • 2PC & Sagas
  • Idempotency & Exactly-Once
Learn/System Design/Distributed Systems

Time & Ordering

8 min Advanced 8 steps

Clocks drift, so order events with logical clocks instead.

Rule
last write wins
Stored
x=1
Node AStoreNode Bclock 50 ms behindx=1 @ t=100keep x=1
request reply failure
In this lessonStep 1 of 8
  1. The problem
  2. Physical clocks
  3. Lamport
  4. Its limit
  5. Vector clocks
  6. Conflicts
  7. HLC, TrueTime
  8. Recap
Step 1 / 8problem

Last write wins, by the wrong clock

The store keeps whichever write has the later timestamp. Node B writes after Node A, but B's clock runs 50 ms behind.

B's newer write carries the smaller timestamp and is silently dropped.

Key idea

Last-write-wins by wall clock can silently lose a newer write when a node's clock runs behind.

←→ step·R replay·Space pause

You'll learn

  • Why wall clocks are unsafe for ordering
  • Run a Lamport clock and know its limit
  • Detect concurrent writes with vector clocks
  • Where HLC and TrueTime fit, and what to say in an interview
Read the full notesDistributed Systems, 2