Merging concurrent edits

Hand-drawn terracotta bands that split apart and braid back together across a dense woven ground of sand, umber and moss strands.

When two devices hold copies of the same data and both change it before they can talk, the copies must be merged. Four methods are in use: conflict-free replicated data types (CRDTs), last-writer-wins, operational transformation (OT) and server reconciliation. Each trades a guarantee against a cost.

The main disputes concern three questions. How much memory do CRDTs cost? Can text edits from different people merge without interleaving their words? Does an app with a central server need CRDTs at all?

This article covers the merge methods. For the idea of keeping the primary copy of data on the user’s device, see Local-first software; for browser storage and offline caching, see Offline web apps.

Four methods and what they guarantee

Each method gives a different guarantee and charges a different price. Reconciling optimistic replication, where replicas accept edits before they synchronise, is generally complex, and ad-hoc approaches are error-prone (Shapiro et al., 2011).

MethodGuaranteeCost
CRDTReplicas converge without foreground synchronisationMetadata can grow without bound; text can interleave
Last-writer-winsA total order without consensusSome updates are lost
Operational transformationConcurrent operations are transformed against each otherRestricted operation types; decentralised algorithms often wrong; server load
Server reconciliationThe server’s order is finalUndoable data structures; costlier remote updates

CRDTs

A CRDT is a data type designed so that replicas of a shared object converge without foreground synchronisation (Shapiro et al., 2011). Replicas can proceed independently, stay available during network partitions and converge deterministically (Almeida, 2023). Their costs are metadata that some designs let grow without bound, and garbage collection that needs weak synchronisation (Shapiro et al., 2011).

Last-writer-wins

Last-writer-wins keeps the most recent write and discards the rest. It gives a total order without consensus, but some updates are inherently lost (Shapiro et al., 2011).

Operational transformation

In OT, operations do not commute by design, so the order in which they are applied matters. A replica that receives an operation transforms it against concurrent updates before applying it (Shapiro et al., 2011). Oster and colleagues showed that most OT algorithms for a decentralised architecture are incorrect (Shapiro et al., 2011). OT also restricts the operations a system can use, and the number of transformation cases grows quadratically with the number of operation types. With many simultaneous active users it can struggle, and the server keeps an operation log (Weidner, 2024).

Server reconciliation

Server reconciliation lets a client apply its own edits at once and then defer to the server’s order. The client undoes its pending local operations, applies the remote ones, then redoes the pending ones (Weidner, 2024). It needs special support from the local data structures, and the undo and redo make remote updates costlier (Weidner, 2024). Replicache, a sync library, rebases pending mutations onto the server’s patch and treats the server as authoritative (Rocicorp LLC, n.d.).

Interleaving in shared text

Both CRDTs and OT can merge concurrent insertions at the same position into interleaved, unreadable text (Weidner & Kleppmann, 2025). The authors of the Fugue algorithm say most existing replicated-list algorithms have this flaw and that the problem went unnoticed for decades. They define a property called maximal non-interleaving and prove that their FugueMax algorithm satisfies it. Fugue performs comparably to state-of-the-art CRDT libraries (Weidner & Kleppmann, 2025).

Metadata growth and cleanup

Studies disagree on whether CRDT memory cost is a serious problem. For many CRDT types, the metadata that orders operations and handles removals grows without bound, and this is an open issue (Bauwens & Gonzalez Boix, 2019; Bauwens & Gonzalez Boix, 2020). The local-first authors report that Automerge performance and memory and disk use became a problem because CRDTs store all history (Kleppmann et al., 2019).

Cleaning up the metadata is not coordination-free. Garbage collection by causal stability, meaning knowing that every replica has seen an update, can start only after causal information has arrived from every node. If one replica performs no operation, no metadata can be removed (Bauwens & Gonzalez Boix, 2019; Bauwens & Gonzalez Boix, 2020). To the best of the authors’ knowledge, only one earlier work proposed a general scheme for removing CRDT metadata. It assumed a fixed network with a known number of replicas (Bauwens & Gonzalez Boix, 2019).

The Fugue authors argue the reverse for text. On a real editing trace, a text CRDT used about 23 bytes per character, or 13 counting tombstones (markers left for deleted characters). They say this refutes the common criticism of excessive per-character overhead. Simpler variants used 618 and 685 bytes per character (Weidner & Kleppmann, 2025).

A newer algorithm, Eg-walker, targets the same problem from another side. Its authors report an order of magnitude less memory than existing CRDTs in the steady state, and merges of long-running branches orders of magnitude faster than OT. They describe CRDTs as slow to load and memory-hungry, and OT as slow to merge files that diverged during offline editing (Gentle & Kleppmann, 2025). In their evaluation, their own OT implementation took 6 seconds on one asynchronous trace and 1 hour on another (Gentle & Kleppmann, 2025).

Whether a central server needs CRDTs Weak evidence: few or small studies support this

Authors disagree on whether CRDTs are needed when a central server exists. The 2019 local-first paper says CRDTs have the potential to be a foundational technology for local-first software (Kleppmann et al., 2019). Weidner argues that with a central server, CRDTs and OT are only optimisations over server reconciliation, and calls such architectures likely overkill (Weidner, 2024). He adds that the hard parts of CRDTs and OT remain useful for decentralised collaboration (Weidner, 2024). A CRDT is not required, he says, for optimistic local updates in collaborative text editing with a central server (Weidner, 2025).

The dispute is also part of the question of whether server-authoritative apps count as local-first software.

Developer experience and invariants Weak evidence: few or small studies support this

Evidence on whether CRDTs make collaborative apps easier to build is thin. Slides from a study of CRDT libraries state that no known user study had evaluated whether CRDTs help create multi-user apps (Zhang et al., n.d.).

Merging without conflicts does not keep application rules true. The authors of LoRe say existing local-first tools leave developers to reason about concurrent interactions without automated safety guarantees. Their model verifies developer-supplied safety properties and uses strong consistency through coordination only where required (Haas et al., 2023). The authors of ConLoc likewise say enforcing application-level invariants over replicated data is a challenge that developers handle by manual synchronisation (Köhler et al., 2025).

Further reading

  • Shapiro and colleagues (2011), the foundational study of CRDTs, which also compares them with last-writer-wins and OT (Shapiro et al., 2011).
  • Weidner (2024), a practitioner’s comparison of architectures for apps with a central server (Weidner, 2024).
  • Weidner and Kleppmann (2025), on interleaving and the Fugue algorithm (Weidner & Kleppmann, 2025).
  • Bauwens and Gonzalez Boix (2020), on why CRDT metadata is hard to remove (Bauwens & Gonzalez Boix, 2020).
  • Gentle and Kleppmann (2025), the Eg-walker memory and merge benchmarks (Gentle & Kleppmann, 2025).

Known gaps

What this article cannot tell you yet.

  1. The original operational transformation paper and later work on the correctness of OT algorithms were not researched.
  2. No independent benchmark of CRDT memory on long-lived documents was found; the memory figures come from the authors of the algorithms.
  3. Results of the programmer-experience study of CRDT libraries are not covered beyond one statement in its slides.
  4. No peer-reviewed study of data loss or complexity cost in deployed local-first web apps was found; the evidence on costs concerns algorithms.
  5. The full text of the Simba paper on consistency in mobile sync was not available.

References

Solid source
Rated highly trustworthy by the research, and every passage taken from it was found in it.
Weak source
Rated low, or a passage taken from it was not found in it.
Medium trust
Rated medium by the research.
Not checked
Rated high, but its passages could not all be checked against it.
Show all 13 references