skip to content

For a team wiki's page editor where up to thirty people edit at once and some work offline on trains for an hour, would you merge edits with OT or a sequence CRDT?

level: seniorimportance: must knowfreq 46%

answer

  1. who sits in every edit's path
  2. an hour offline is a long pending list
  3. a transform for each pair of operation types
  4. identities per character cost memory and load
  5. whiteboard: per object, per property

basics

~20 s

A sequence CRDT: hour-long offline edits merge without a central server transforming every operation, at the cost of per-character metadata the page must load, so snapshot it. Always-online editing would make OT the lighter choice. Whiteboard objects need only per-property merge.

solid answer

~50 s

Both are defensible; the constraints decide. OT keeps the client light — the document plus a short queue of unacknowledged operations — but many OT systems put a central server in the path of every edit to order and transform operations, so an hour of offline typing becomes a long pending list transformed against everything others did meanwhile, and rich text multiplies the transformation cases. A sequence CRDT gives every character an identity, so concurrent operations merge in any order on any replica, including the laptop on the train; the server becomes relay, store and gatekeeper rather than transformer. The cost lands in the browser: identity metadata and history that grow with the page's life, so load time and memory need snapshots. For this wiki I'd pick the CRDT. The whiteboard is simpler: shapes have ids and properties, so merging per object and per property, with the server's order breaking ties, suffices.

go deeper

for a junior

Recall that shared editors merge concurrent edits either by adjusting positions (operational transformation) or by giving every character an identity (a sequence CRDT).

for a middle

Explain why a position-based delete must shift after a concurrent insert, what a central server does in many OT designs, and what a server still does when the merge is a CRDT.

for a senior

Pick one for the stated constraints — offline length, the server's role, browser memory and load time — name its cost, say what would flip the choice, and treat the whiteboard separately.

for a principal

Weigh who carries each cost: client memory and snapshot work against a transformation server in every edit's path, and whether the offline promise justifies the replica the product must then maintain.

## The constraints that decide it A **team wiki's page editor** is rich text: headings, lists, tables and inline comments. Two to thirty people may edit one page at once, some edit on a train for an hour with no connection, and pages live for years. Three questions follow from that: - **Who must be in the path of every edit?** If a server has to order and adjust each operation, the laptop on the train cannot finish merging until it reconnects. - **How long can a client diverge?** A few hundred milliseconds of latency and an hour of offline typing are very different loads on the merge. - **What does the browser pay?** Memory, the bytes downloaded on open and the time to parse them, on an ordinary work laptop. ## Operational transformation with a central server **Operational transformation (OT)** sends edits as position-based operations and adjusts ("transforms") each one against concurrent operations it has not yet accounted for. The textbook case: the document is `abc`; one user inserts `x` at position 0 while another deletes the `c` at position 2. Applied after the insert, the delete must become a delete at position 3, or it removes `b` instead. Many OT systems put a **central transformation server** in the middle: it fixes one order for all operations, and each browser keeps its own unacknowledged edits in a pending queue, transforming incoming operations against them. That keeps the client light — it holds the current document and a short queue, and the history lives on the server. The costs: - the server sits in the path of every edit, so offline work becomes a growing pending list that must be transformed against everything others did meanwhile once the laptop returns; - a rich-text model multiplies the cases: with application-specific operations, every pair of operation types (split a list item, merge table cells, move a heading) needs a transformation function, and published critiques call OT's correctness proofs complicated and error-prone even for plain insert and delete; - undo needs transformation rules of its own — many published OT algorithms support no undo at all. ## A sequence CRDT A **sequence CRDT** (a conflict-free replicated data type for ordered content) is an alternative to OT for a real-time editor. Each character or element carries a unique identity, and operations refer to identities instead of positions, so concurrent operations can be applied in any order on any replica and still converge. The laptop on the train merges by itself, and the server stops being a transformer: it relays updates, persists them, checks permissions and writes snapshots. The costs move into the browser: identity metadata for every element, deleted content the merge may still need, and a history that grows with the page's life — all of which the page downloads and holds in memory to edit. How that metadata behaves in general is the subject of the question on CRDT costs at scale; here it matters as load time and memory. ## Side by side | Concern | OT with a central server | Sequence CRDT | |---|---|---| | Server's role | orders and transforms every operation | relays, stores, authorises, snapshots | | An hour offline | long pending list transformed on return | merges locally, in any order | | Browser memory | document plus a pending queue | document plus identities and history | | Page open | fetch the current document | fetch state with metadata; needs snapshots | | Rich-text structure | a transformation function per operation pair | nested ordered and keyed types | | Undo of own edits | inverse transformed past later edits | inverse aimed at element identities | ## The call for this wiki 1. Use a **sequence CRDT** for the page body, because hour-long offline editing is a stated requirement. 2. Keep a **server** for relay, storage, access checks, search indexing and notifications — a peer that stores and forwards, not the place every merge happens. 3. Bound the browser's cost with **snapshots**, so a two-year-old page opens from compacted state instead of its whole history. 4. If the product drops offline editing (offline becomes read-only and drops are buffered for seconds), **OT with a central server** is equally sound and lighter on the client. Choose by the requirement, not by fashion. ## The whiteboard is a different shape The same product's **whiteboard** holds sticky notes, shapes and connectors: objects with ids and properties (position, size, colour, text, endpoints), not one long sequence. Concurrent edits mostly touch different objects or different properties of one object, so a **per-object, per-property merge** suffices — each property holds one value, and when two people set the same property the server's order picks the one that stays. Stacking order can use sortable ordering keys placed between neighbours instead of positions. Two spots still need care: - text typed into one note by two people at once — give that text the sequence type; - a connector whose shape was deleted concurrently — an application rule hides or removes the dangling connector.

  • Would the page send every keystroke as its own message?
    No. Coalesce consecutive keystrokes into one operation and flush on a short timer of tens of milliseconds, on a typing pause, and when the tab is hidden. An OT client commonly keeps one batch in flight and composes newer typing into a pending batch until the acknowledgement arrives; a CRDT client can send several unacknowledged updates because order does not matter. Collaborators see text a beat later; message count drops sharply.
  • When would you choose OT for this wiki instead?
    When editing is online-only — offline shows the page read-only and short drops are buffered for seconds — and a central server is acceptable in every edit's path. Then OT keeps the browser to the document plus a pending queue, history stays on the server, and page open is just the current document. The hour on the train is what tips it the other way.
  • If you choose a CRDT, what does the server still do?
    Almost everything except transforming: it authenticates and checks access on every update, persists updates, relays them to the other editors, writes snapshots, indexes pages for search and sends notifications. It is a peer that stores and forwards, so the merge no longer depends on it, but the product still does.

  • OT always requires a central server, so it can never support offline edits.
  • With a CRDT the product no longer needs a server at all.
  • A CRDT converges, so users never need to see a conflict.
  • Last-writer-wins on the whole paragraph is good enough for shared text.
  • Send the full document on every change and keep the newest copy.