Patterns

CRDTs

A conflict-free replicated data type lets every replica accept writes on its own and still merge to the same state without coordination.

A CRDT is a data structure built so that any two replicas that have seen the same updates reach the same state, whatever order the updates arrived in. The crdt.tech site describes them as taking care of conflict resolution for you.

Use one when replicas must keep writing while disconnected. Two phones edit a shared shopping list on a plane. Each adds items offline, and on landing they sync. With an add-wins set, an item one phone added is kept even if the other removed it concurrently, and both phones show the same list with no server deciding. Counters, sets, registers and text sequences all have CRDT forms, and collaborative editors use them.

The cost is design freedom. Each type has fixed merge rules, so a rule you did not want, like add-wins, is baked in. Metadata grows, since replicas often keep tombstones for removed items or a vector of per-replica counters, and the state needs compaction. Invariants like "stock never below zero" cannot be enforced without coordination, which is the point of the trade. Pick CRDTs for data where any merged result is acceptable.

Nearest in Quorum#

The game has no CRDTs. The closest idea is a store that takes writes on several replicas and reconciles later. A Wide-column Store with leaderless replication does this, and the Research Leaderless replication unlocks it. Its stale reads are what eventual consistency costs, and a weak quorum is the dial. Read Replication strategies and Consistency models for context.

References#