A Conflict-Free Replicated Data Type (CRDT) is a data structure that can be replicated across multiple independent nodes, modified concurrently without coordination, and will deterministically converge to the same final state through mathematically sound merge operations. CRDTs work by ensuring all operations are commutative (order-independent), associative, and idempotent. Each replica maintains its own state and a history of operations. When replicas synchronize, they exchange these operations or their resulting states, and the merge function combines them into a consistent result, guaranteeing eventual consistency without central coordination or locking.
Key mechanisms include:
- Operation-based (CmRDTs): Replicas exchange the operations themselves (e.g., 'add element X').
- State-based (CvRDTs): Replicas exchange their full state, and the merge function (like a join in a lattice) combines them.
- Causal Context: Many CRDTs track metadata, like version vectors, to avoid applying duplicate operations.