Nyskra Knowledge / Distributed Systems

Conflict-Free Replicated Data Types (CRDTs)

CRDTs help independently updated data replicas converge without central conflict resolution. Learn how replicated state, convergence, and state-based and operation-based CRDTs work.

Definition

Conflict-free replicated data types (CRDTs) are replicated data types designed so that independent replicas can accept updates without coordinating each operation and reach equivalent logical states after incorporating the same relevant updates, under the data type's delivery assumptions.

Also known as: CRDT, CRDTs, Conflict-free replicated data type

On this page

Imagine you and another person maintaining the same shopping list. You add coffee on your phone while traveling without a network connection. At the same time, the other person adds bread on a different device. Neither device knows about the other’s edit yet.

When the devices reconnect, the application should preserve both additions. It should not discard the coffee because the bread arrived later, or require a central server to examine the complete list before either person is allowed to make a change.

Conflict-free replicated data types (CRDTs) are one way to solve this class of problem. They are data structures designed for multiple independently updated copies, with carefully defined rules for how those copies become consistent again.

CRDTs are especially relevant to local-first software, collaborative applications, and systems that continue working through network interruptions. They address a fundamental problem of distributed systems: how to combine changes made without continuous coordination.

What makes a replicated data type conflict-free?

The name can sound stronger than it is. A CRDT does not mean that different people will never make competing edits. It means that the data type has rules that can reconcile independently accepted changes into a deterministic result under its stated assumptions.

There are two essential ideas:

  • Independent progress: A replica can accept supported local updates without waiting for another replica to approve every operation.
  • Predictable convergence: Once correct replicas have incorporated the same relevant updates, the CRDT’s rules produce equivalent logical states, even if those replicas worked independently in the meantime.

For example, consider a shared counter whose initial value is zero. Two offline devices each increment it once. If the data type understands these as two independent increments, the reconciled result can be two, rather than whichever device happened to submit its current value last.

CRDTs achieve this through the design of the data type, not by magically resolving any possible application conflict. Counters, sets, maps, sequences, and other structures can have CRDT variants, but each must define how concurrent operations behave.

The general definition of convergence belongs to our Distributed Systems reference. Here, we focus on the specific mechanisms through which CRDTs achieve it.

Replicated State

Definition

Replicated state is information maintained in separate local copies at multiple nodes, where each copy can reflect locally accepted updates before changes are exchanged and reconciled with other replicas.

Also known as: Replica state, Local replica state

A replica is a local copy of shared information or of the information required to reconstruct its current logical state. In a CRDT system, different replicas can temporarily represent different states because their owners have received different updates.

Suppose a shared list starts empty:

  1. Phone A adds “Coffee” while offline.
  2. Phone B adds “Bread” without seeing the first addition.
  3. Each phone immediately displays its own local change.
  4. After synchronization, both incorporate the two additions according to the shared data type’s rules.

During the offline period, both local states are valid views of incomplete information. The goal is not to prevent them from differing at every moment, but to make their eventual reconciliation well-defined.

There is an important distinction between a replica’s logical state and the bytes it stores or exchanges. Two replicas might use different database layouts, indexes, or histories while still representing equivalent shared information.

Not every participant in a distributed system needs the same readable replica. In an end-to-end encrypted system, authorized devices may reconstruct private application state while an intermediary stores only encrypted updates. The intermediary is involved in replication without being able to interpret the underlying records.

Why does receiving updates in a different order matter?

Network messages can be delayed, retried, duplicated, or delivered along different paths. One device might learn about a new shopping-list item today, while another receives that same change tomorrow. Two independent changes may arrive in opposite orders.

A naive approach is to overwrite the entire remote copy with whichever copy arrived most recently. That can cause a valid offline edit to disappear. Using wall-clock timestamps alone also cannot establish whether one edit was based on knowledge of another.

CRDTs avoid relying on arbitrary arrival order for their convergence property. They instead define merge or application rules with algebraic properties appropriate to the selected data type.

Convergence in CRDTs

Definition

Convergence in CRDTs is the property that correct replicas reach equivalent logical states after incorporating the same relevant updates, using the CRDT's defined state-merge or operation-application rules under the required delivery assumptions.

Also known as: CRDT convergence, Strong convergence in CRDTs

CRDT convergence is a particular realization of the broader distributed-systems concept of convergence. In CRDT terminology, a central goal is strong convergence: correct replicas that have incorporated the same relevant updates represent equivalent logical states.

This is a component of strong eventual consistency. The word eventual matters: a disconnected replica cannot incorporate an update that never reaches it. The convergence rules of a CRDT do not themselves guarantee network connectivity, durable storage, or eventual message delivery.

How a CRDT achieves convergence depends on its model:

  • State-based CRDTs merge independently developed states using a mathematically compatible merge operation.
  • Operation-based CRDTs apply propagated updates whose effects are compatible under the algorithm’s required message-delivery conditions.

In both cases, correctness depends on using the same intended CRDT semantics on the participating replicas. Incompatible implementations, missing dependencies, invalid operations, or malicious modifications are not made harmless by the name CRDT.

An important practical consequence is that a CRDT’s state may converge without preserving every intermediate representation. For example, a set’s final contents can be the same even though updates were seen in different orders. Conversely, for collaborative text or rich application data, the particular CRDT determines precisely which ordering and editing semantics users will observe.

For a formal treatment, see Shapiro, Preguiça, Baquero, and Zawirski, Conflict-free Replicated Data Types (2011).

Two fundamental CRDT approaches

CRDTs are often divided into state-based and operation-based families. Both are designed for convergence, but they differ in what is exchanged between replicas and which delivery guarantees the communication system must provide.

State-Based CRDTs

Definition

State-based CRDTs propagate mergeable replica state and combine compatible states with an associative, commutative, and idempotent merge operation, allowing independently updated replicas to converge.

Also known as: State-based CRDT, CvRDT, Convergent replicated data types

A state-based CRDT, also called a CvRDT (Convergent Replicated Data Type), exchanges mergeable state. Each replica updates its local state, and another replica can later incorporate that state through a defined merge operation.

The central idea is that merging must remain safe even when the same states arrive in different orders or arrive more than once. In the classical state-based model, the merge operation is:

  • Commutative: Merging A with B gives the same logical result as merging B with A.
  • Associative: Grouping successive merges differently does not change the result.
  • Idempotent: Merging a state with itself does not introduce an additional change.

These properties are captured mathematically by a join-semilattice. Local updates must also evolve the state in a compatible, monotonic way under the data type’s defined ordering.

An illustrative example is a grow-only distributed counter. Each replica records its own contribution. When states are merged, the system retains the greatest observed contribution for each replica. The shared value is the sum of those contributions, so separate increments are not accidentally overwritten.

The obvious trade-off is transmission cost: sending an entire growing state repeatedly can be expensive. Delta-state CRDTs can reduce that cost by exchanging suitable incremental state fragments, while retaining carefully specified merge and delivery requirements.

Operation-Based CRDTs

Definition

Operation-based CRDTs propagate the effects of updates to other replicas, with concurrent effects designed to commute under the operation delivery and ordering guarantees required by the data type.

Also known as: Operation-based CRDT, Op-based CRDT, CmRDT, Commutative replicated data types

An operation-based CRDT, also called a CmRDT (Commutative Replicated Data Type), propagates operations or their effects instead of repeatedly exchanging the complete state.

A replica accepts an operation locally, such as adding an item to a set. It then communicates the operation’s effect so that other replicas can apply it to their own state.

For correctness, effects of concurrent operations must commute in the way required by the data type. That means independent operations can be applied in different allowed orders without producing incompatible results.

Operation-based CRDTs also rely on appropriate message-delivery properties. Depending on the design, these can include reliable delivery, causal ordering, and prevention or handling of duplicate application. Merely broadcasting arbitrary application commands in an arbitrary order does not make a system a CRDT.

For example, consider a replicated set supporting both adding and removing an item. What should happen if one replica adds the item while another, unaware of that addition, removes it? The answer depends on the specific set semantics. An add-wins set and a remove-wins set can both be designed to converge, but they encode different decisions about concurrent changes.

This illustrates the strength and responsibility of a CRDT design: the outcome follows explicitly chosen, consistent rules rather than the accidental timing of incoming messages.

For a broader research overview, see Preguiça, Baquero, and Shapiro, Conflict-free Replicated Data Types (CRDTs) (2018), and Almeida, Approaches to Conflict-free Replicated Data Types (2023).

Are CRDTs the same as conflict resolution?

CRDTs provide one family of principled methods for conflict resolution. They make certain types of concurrent modification deterministic without requiring all participants to consult a central authority before acting.

But their guarantees are about the data type’s defined operations and state, not about every imaginable business rule.

For example, a replicated set can define precisely how concurrent additions and removals are reconciled. That does not settle a disagreement about whether a shared project should be deleted, or whether two users intended different meanings for the same document title.

Likewise, constraints such as reserving the final available seat or allowing exactly one participant to claim a resource may require coordination or specialized mechanisms. CRDTs are powerful tools, not replacements for designing application semantics.

Another subtle point: a last-write-wins register can itself be implemented as a CRDT if it defines deterministic ordering and merge rules. It can converge perfectly while discarding one of two competing values from the user-facing result. Convergence and preservation of every user intention are different goals.

What changes when synchronization is end-to-end encrypted?

Many server-centered applications perform content-aware conflict resolution on the server because the server can read the records being synchronized.

An end-to-end encrypted synchronization service cannot ask a server that lacks the decryption keys to inspect private record contents and choose their meaning. The server can still store, route, order, or acknowledge encrypted messages, but content-level reconciliation must happen where the protected data can be decrypted, typically on authorized clients.

CRDTs are relevant in this setting because their rules can enable those clients to process independently produced changes and arrive at equivalent logical states. The algorithm’s delivery and authorization assumptions remain important, and the encryption protocol must separately protect the confidentiality and integrity of the exchanged information.

This is one of the links between distributed systems, data synchronization, and local-first software: applications can accept edits locally, exchange protected changes later, and reconcile them without making the server a reader of private information.

CRDTs and Nyskra

Nyskra develops local-first applications that keep personal information useful on a person’s own devices while supporting private synchronization. Independent devices and intermittent connectivity are central challenges in this field, and CRDT research provides valuable background for understanding them.

Different replicated data types address different synchronization requirements, including ordering, deletion, validation, permissions, and concurrent changes. A well-designed application must consider those requirements alongside end-to-end encryption and zero-access privacy.

For users, the goal is simple: work with personal information when it matters, including offline, and find it available on other authorized devices after synchronization. Nyskra Sync is designed around that experience, while this article explores the general principles behind replicated data.

Further reading

For the underlying terminology, start with Data Replication, Convergence, and Concurrent Updates in our Distributed Systems reference. Eventual Consistency explains why replicas may temporarily differ, while Synchronization Conflicts covers the cases where application semantics require additional decisions.

Our Data Synchronization and Local-First Software articles connect these ideas to real applications. For the relationship between collaborative data structures and user control, see Kleppmann, Wiggins, van Hardenberg, and McGranaghan, Local-first software: You own your data, in spite of the cloud (2019).