Distributed patterns / Advanced / 5 min / Updated
CRDTs vs last-write-wins: resolving conflicting writes
Split two regions, keep counting likes on both sides, then heal. Last-write-wins loses likes, vector clocks need merge code, CRDTs merge themselves.
Start the simulation → Change the load, break a part, watch what happens. Free, no sign-up.
In short
What is CRDTs and conflicts?
CRDTs are data types whose replicas always merge to the same result, whatever order updates arrive in.
Why does it matter?
Multi-region or offline-first apps accept writes on both sides of a network split.
What is the trade-off?
LWW is simple but loses data; vector clocks detect conflicts but need merge code; CRDTs cost extra metadata.
How do you explain it in an interview?
"Likes as a per-region CRDT counter; cart as an observed-remove set; never last-write-wins for money."
Check yourself
What happens with last-write-wins after a network split?
Answer: The version with the later timestamp wins and the other side loses its updates. LWW is simple but drops concurrent updates, and clock skew makes it worse.
What do vector clocks give you?
Answer: Detection that two versions are concurrent, so the app can merge them. They track causality, not wall-clock time; merging is still the job of your code.
Why does a CRDT counter never lose increments?
Answer: Each replica counts in its own slot and the merge adds the slots. Merges are commutative and idempotent, so any order of syncing gives the same total.