CRDTs & Conflict Resolution
Lesson, slides, and applied problem sets.
View SlidesLesson
CRDTs & Conflict Resolution
Why CRDTs
In distributed systems, updates can arrive out of order. Conflict-free Replicated Data Types (CRDTs) guarantee convergence without coordination.
Key idea
A CRDT defines a merge function that is:
- Commutative (A ⊔ B = B ⊔ A)
- Associative (A ⊔ (B ⊔ C) = (A ⊔ B) ⊔ C)
- Idempotent (A ⊔ A = A)
These properties ensure replicas converge even with duplicated or reordered updates.
What you will build
- G-Counter merge (grow-only counter)
- LWW Register merge (last-write-wins)
- PN-Counter merge (inc/dec)
- OR-Set merge (observed-remove set)
- MV-Register merge (concurrent values)
Module Items
G-Counter Merge
Merge two grow-only counters by element-wise max.
PN-Counter Merge
Merge PN-counters by element-wise max.
LWW Register Merge
Merge two LWW registers by timestamp and node ID tie-breaker.
OR-Set Merge
Merge OR-sets and return present elements.
MV-Register Merge
Merge MV-registers and keep concurrent values.