concept
CRDT (Conflict-free Replicated Data Type)
created 2026-05-25 distributed-systems · crdt · convergence · replication · local-first
CRDT (Conflict-free Replicated Data Type)
A data structure designed so that concurrent updates from multiple nodes always converge to the same result regardless of order, without coordination. For applicable data types, this makes the cap-theorem|CAP tradeoff disappear: the math handles consistency, so the network only needs to deliver updates eventually.
The two guarantees
For a data structure to be a CRDT:
- Commutative — order of operations doesn’t matter (
a ∘ b == b ∘ a). - Idempotent — duplicate messages don’t corrupt state (
a ∘ a == a).
Guarantee both and concurrent writes on different nodes always converge once they exchange state. No locking, no consensus protocol, no central authority.
Common types
| Type | Use case |
|---|---|
| G-Counter (grow-only) | Page views, likes — increments only |
| PN-Counter (positive-negative) | Inventory, balances — increments and decrements |
| OR-Set (observed-remove) | Tags, members — add/remove with last-add-wins on conflict |
| LWW-Register (last-writer-wins) | Single-value fields with a tiebreaker (timestamp + node id) |
(Sequence CRDTs for collaborative text — RGA, Yjs’s YATA, egwalker — are a richer family layered on top.)
Worked example: YouTube view counter
Multiple servers in different regions incrementing the same counter simultaneously, no locks:
- Each node tracks its own increments locally.
- Merge by summing per-node contributions.
- Addition is commutative → no race condition possible.
- It mathematically cannot lose a count.
What CRDTs do not solve
- Uniqueness constraints — “this email must be globally unique” still needs coordination at write time. CRDTs don’t replace consensus for invariants that span the whole system.
- Most business operations — cross-service workflows (charge card → ship order → notify) are not CRDTs. Use the saga-pattern there.
- Arbitrary application state — every type that needs conflict-free merge has to be designed for it; you can’t sprinkle CRDT-ness on existing objects.
Real-world adoption (from the source video)
| System | CRDT status |
|---|---|
| Redis Enterprise (geo-replication) | True CRDTs, no central coordinator |
| GoodNotes | Ships automerge to millions of monthly users |
| Figma (canvas) | Influenced, not true CRDTs — central server serializes, last-writer-wins per property |
| Figma (text editing, 2025) | Uses egwalker — constructs a CRDT structure transiently to resolve text conflicts, then discards it |
| Notion | CRDT-influenced |
| Apple iCloud | CRDT-influenced |
Libraries
- yjs — most-deployed JS/TS CRDT framework, dominant in collaborative-editor space
- automerge — JSON-like CRDT, document-oriented, GoodNotes-grade production use
- egwalker — text-only sequence CRDT algorithm (Josephg, 2024)
See also
- cap-theorem — the broader problem CRDTs sidestep
- pacelc — even without partitions, consistency costs latency; CRDTs are a way out for compatible types
- local-first-software — CRDTs are the natural sync layer
- saga-pattern — what to use when CRDTs don’t apply