Notesreplication🌱 seedling

Last Write Wins

Also: LWW · Last Writer Wins

Resolve conflicting versions by keeping the one with the highest timestamp. It always converges, and it silently discards every other concurrent write.

Why it exists

It's the simplest rule that makes replicas agree: no application code, no siblings, no metadata beyond a timestamp.

How it works

  • Every write carries a timestamp (client or coordinator clock, or a logical clock).
  • On conflict, each replica keeps the higher timestamp; ties break deterministically.
  • "Last" is defined by clocks that disagree (Clock Skew): a write that really happened later but was stamped by a slow clock loses.

Trade-offs

Gains Costs
trivial convergence acknowledged writes vanish without error
no merge logic correctness depends on clocks
small metadata concurrent updates are lost, not merged

In practice

  • Cassandra applies LWW per cell, using write timestamps.
  • DynamoDB global tables resolve concurrent multi-Region writes per item by "last writer wins".
  • Jepsen, 2013: Riak with LWW lost 1,434 of 2,000 acknowledged writes (71.7%) under concurrent writes with no partition; a CRDT set lost none.

Pitfalls

  • Safe only when keys are written once (immutable events with unique IDs) or losing a concurrent write is acceptable.
  • Using it for counters or collections: you get one replica's total, not the sum.

Recall

These cards are also in your review deck, scheduled with spaced repetition.