CRDTs & Conflict Resolution

Difficulty
Importance

The problem

In an eventually consistent, multi-writer system, two replicas can accept conflicting concurrent updates before they sync — someone has to decide how those conflicting versions get merged back into one, ideally without losing data or requiring a human referee for every conflict.

Why now

Distributed consistency models already established that eventual consistency permits temporary disagreement between replicas; algebraic structures already proved that operations with the right properties (associativity, commutativity) can be combined safely in any order — CRDTs are the direct, deliberate application of that algebra to make merging conflicting replicas automatic and always correct.

Mental model

A CRDT is a data structure specifically designed so merging two divergent replicas is a mathematical guarantee, not a guess — because the merge operation is built to be associative, commutative, and idempotent (a semilattice), the same result comes out no matter what order updates are merged in or how many times a merge is retried. This is algebraic-structures' abstract promise, cashed out as an actual, always-correct conflict resolution strategy.

Requires

Used in

Projects

  • Implement a grow-only counter CRDT (each replica tracks its own increments; total is the sum across replicas) and demonstrate it merges correctly regardless of merge order
  • Implement a simple last-write-wins register CRDT and explain the specific data loss risk it accepts in exchange for simplicity

Examples

  • A grow-only counter CRDT lets each replica increment its own slice independently; the merged total is always correct regardless of which replica syncs with which, in what order
  • Two users editing the same document offline, then syncing, can have their changes merged automatically by a CRDT-based text structure without a manual conflict-resolution step

Resources

Mastery checklist