Black Friday: 30% off every plan through November 30. See the prices
SysDesignPrep.com
Study guide

Updated 24 October 2026

CRDTs vs operational transformation

How collaborative editors merge concurrent edits: the problem of concurrent operations, operational transformation with a central server, CRDTs for text and data, convergence and intent preservation, metadata and performance costs, presence and cursors, and which to choose.

Reading is half of it. Now try it in an interview.An AI interviewer asks you to design Google Docs, out loud or typed, and scores the answer for your level. Or watch a sample interview first, free with no sign-up to start.
Start an AI mock

Try it yourself, in a playground:Vector clocksCRDTs

Google Docs, Figma, Notion and many other tools let several people edit the same document at once, each seeing their own changes instantly. When two people type at the same place at the same moment, both edits must survive and every copy must end up identical. Two families of algorithms solve this: operational transformation (OT) and conflict-free replicated data types (CRDTs). "Design Google Docs" is mostly about choosing between them and building the system around the choice.

The problem

Alice and Bob both start with "abc".

  • Alice inserts "X" at position 1: "aXbc".
  • Bob, at the same time, deletes the character at position 2 ("c"): "ab".

If each applies the other's operation naively, Alice deletes position 2 of "aXbc" (which is "b", the wrong character), and the copies diverge. Positions shift under concurrent edits, so operations cannot be applied blindly.

Requirements:

  • Convergence: all replicas reach the same state once they have seen the same operations.
  • Intent preservation: each edit has the effect its author intended (Bob meant to delete "c").
  • Responsiveness: local edits apply instantly, without waiting for the server.

Operational transformation

Each operation is transformed against concurrent operations that were applied first, adjusting positions. In the example, Bob's "delete at 2" is transformed against Alice's "insert at 1" to become "delete at 3".

How it is deployed (as in Google Docs):

  • A central server receives operations, decides a single order, transforms incoming operations against those already applied, and broadcasts the result.
  • Each client applies its own operations immediately, sends them with the document version they were based on, and transforms incoming server operations against its own unacknowledged ones.

Characteristics:

  • Compact operations and documents; little metadata.
  • Requires a central authority for ordering in practical implementations; offline editing and peer-to-peer are hard.
  • Transformation functions are notoriously tricky to get right for rich content (tables, formatting).

CRDTs

A CRDT is a data structure designed so that concurrent updates commute: applying the same set of operations in any order gives the same result, with no central coordination.

For text, sequence CRDTs give each character a unique, ordered identifier (based on replica id and a counter, positioned relative to its neighbours). Inserts reference identifiers, not positions, so they do not shift; deletes mark identifiers as removed (tombstones). Libraries such as Yjs and Automerge implement this efficiently.

Other CRDTs cover counters (grow-only, increment and decrement), sets (observed-remove sets), registers (last-writer-wins) and maps, so whole JSON-like documents can be CRDTs. See offline-first apps and sync.

Characteristics:

  • Works offline and peer-to-peer; any replica can merge any other's changes.
  • The server can be a simple relay and store, not a transformation engine.
  • Metadata overhead: identifiers and tombstones per character; modern implementations compress this heavily, but large, long-lived documents need garbage collection or compaction.
  • Some merge results are surprising for users (interleaving of concurrent inserts in older algorithms), though newer algorithms reduce this.

Comparison

OTCRDT
Coordinationcentral server orders operationsnone required
Offline and peer-to-peerdifficultnatural
Metadata sizesmalllarger (ids, tombstones), compressible
Server roletransforms and ordersrelays, persists, optionally compacts
Complexitytransformation correctnessdata structure design and memory
Used byGoogle Docs (historically)Figma-style and local-first apps, Yjs and Automerge users

The system around the algorithm

Either way, you need:

  • Real-time transport: WebSockets from each client to a collaboration server that hosts the document session. See WebSockets vs SSE vs long polling.
  • Session routing: all editors of a document connect to the same server (or a small group), found through consistent hashing or a session registry. See presence and connection management.
  • Persistence: an append-only log of operations plus periodic snapshots, so loading a document does not replay its whole history. See event sourcing and CQRS.
  • Presence and cursors: ephemeral, high-frequency updates sent to collaborators but not stored.
  • Permissions checked on connect and on each operation. See authorization and permissions.
  • Version history: named snapshots and the ability to restore.

Choosing

  • Always-online collaboration with a central service, rich text, and a team ready to own transformation logic: OT is proven.
  • Offline editing, mobile apps, peer-to-peer, or a general data model beyond text: CRDTs.
  • Many new systems choose CRDTs with a server that relays, persists and compacts, combining easy offline support with central storage.

In the interview

For Design Google Docs: explain the concurrent edit problem with a two-user example, choose OT with a central session server (or a CRDT with a relay server) and justify it, then cover WebSocket sessions routed by document id, an operation log with snapshots, presence, permissions and version history.

Checklist

  • State the convergence and intent preservation requirements.
  • OT: central ordering and transformation; CRDT: commutative merges with unique ids.
  • Session routing so a document's editors share a server.
  • Operation log plus snapshots; tombstone or history compaction.
  • Ephemeral presence; permissions on every operation.

Questions people ask

What is operational transformation (OT)?

Operational transformation merges concurrent edits by transforming each operation against the concurrent operations applied before it, adjusting its positions. If Alice inserts "X" at position 1 while Bob deletes the character at position 2, Bob's operation becomes "delete at 3" so it still removes the character he meant. In practice a central server decides a single order of operations, transforms incoming ones against those already applied, and broadcasts the result.

What is a CRDT?

A CRDT (conflict-free replicated data type) is a data structure designed so that concurrent updates commute: applying the same set of operations in any order gives the same result, with no central coordination. Sequence CRDTs for text give each character a unique, ordered identifier based on a replica id and a counter, so inserts reference identifiers rather than positions and deletes leave tombstones. Other CRDTs cover counters, sets, registers and maps.

OT vs CRDT: which should you use for collaborative editing?

Use OT for always-online collaboration with a central service and rich text, when the team is ready to own the transformation logic; use CRDTs for offline editing, mobile apps, peer-to-peer or a general data model beyond text. OT keeps metadata small but needs a central server to order operations. CRDTs need no coordination but carry identifiers and tombstones per character. Many new systems choose CRDTs with a server that relays, persists and compacts.

How does Google Docs merge concurrent edits?

Google Docs has historically used operational transformation with a central server. Each client applies its own edits immediately and sends them with the document version they were based on; the server decides a single order, transforms incoming operations against those already applied, and broadcasts the result. Each client transforms incoming server operations against its own unacknowledged ones, so every copy converges while local typing stays instant.

Why can't collaborative editors apply concurrent edits directly?

Concurrent edits shift positions, so applying another user's operation blindly can change the wrong character and make the copies diverge. If Alice and Bob both start with "abc", Alice inserts "X" at position 1 and Bob deletes position 2 ("c"), then Alice applying Bob's delete to "aXbc" removes "b" instead. A collaborative editor must guarantee convergence, preserve each author's intent and still apply local edits instantly.

What are the downsides of CRDTs?

The main cost of CRDTs is metadata: identifiers and tombstones per character. Modern implementations compress this heavily, but large, long-lived documents still need garbage collection or compaction. Some merge results can also surprise users, such as interleaved concurrent inserts in older algorithms, though newer algorithms reduce this. The complexity moves from transformation correctness to data structure design and memory.