The CRDT Dictionary: A Field Guide to Conflict-Free Replicated Data Types
12 days ago
- #CRDT
- #eventual-consistency
- #distributed-systems
- CRDTs (Conflict-Free Replicated Data Types) enable distributed systems to handle concurrent writes without coordination or consensus, ensuring eventual consistency.
- Key properties of CRDTs include commutativity, associativity, and idempotence in merge operations, allowing deterministic convergence of replicas.
- State-based CRDTs (CvRDTs) transmit full state for merging, while operation-based CRDTs (CmRDTs) transmit operations, requiring causal delivery.
- Common CRDT examples include G-Counters (grow-only), PN-Counters (supports decrement), G-Sets (grow-only), 2P-Sets (add/remove), and OR-Sets (observed-remove with tags).
- Sequence CRDTs like RGA, WOOT, and Logoot handle ordered data with unique IDs or position identifiers to manage concurrent inserts and deletes.
- Practical challenges with CRDTs include garbage collection of metadata (e.g., tombstones), clock synchronization for LWW variants, and space overhead for tracking replicas or tags.
- Delta CRDTs optimize bandwidth by transmitting only changes (deltas) instead of full state, improving efficiency in production systems like Riak and Automerge.
- Advanced topics include causal CRDTs using version vectors, tree CRDTs for hierarchical data, and hybrid approaches combining different CRDT types for complex use cases.
- CRDTs trade strong consistency for availability and partition tolerance, making them suitable for collaborative editing, distributed counters, and offline-first applications.