Concepts/Architecture TechniquesAdvanced5 min

CRDT

Let distributed replicas accept local edits and merge without conflicts.

CRDTcollaborationconflict-resolutionreal-time

Prerequisites

What it is

A conflict-free replicated data type is a data structure designed so replicas can update independently and merge into a consistent result.

Why it matters

Collaborative apps, offline-first clients, and multi-region systems need to accept changes without always coordinating through one leader.

How it works

CRDTs encode operations or state with merge rules that are associative, commutative, and idempotent. That means replicas can receive changes in different orders and still converge.

Initial: "Hello" REPLICA A insert(" World", pos 5) "Hello World" REPLICA B insert("!", pos 5) "Hello!" merge (commutative + idempotent) Converged: "Hello! World" Both replicas reach the same result regardless of operation order
Two replicas diverge with independent edits, then converge to the same state on merge

The merge rules guarantee convergence: operations can arrive in any order, be duplicated, or be replayed, and every replica ends up in the same state.

When to use it

Use CRDTs for collaborative editing, shared counters, sets, maps, presence-like state, and offline-capable apps where conflicts must resolve automatically.

Tradeoffs / failure modes

CRDT metadata can grow, text editing CRDTs are subtle, and automatic convergence does not always match human expectations.

Tiny example

Two users edit a note offline. When both reconnect, their CRDT operations merge without one edit overwriting the other.

See Collaborative Real-Time Editing and Google Drive.

Seen in deeper dives

Related concepts