KatInterview

Backend design for live multi-user text editing with conflict handling

System DesignModel answer
MediumModel answerSystem Designcollaborative-editingoperational-transformationreal-time

Last updated

Design a server that orders and merges simultaneous keystrokes from many editors on one document, converges all replicas, and survives failures.

A product team is building a shared writing tool where several people can type into the same page at the same moment. Your job is to design the backend. The main focus is the mechanism that handles simultaneous edits to one document, not the front end.

Requirements:

  • Many users can open the same document and edit it together.
  • Other users should see each change within a few hundred milliseconds.
  • Nothing is silently lost or duplicated, and every participant ends up looking at identical content, even when messages arrive late or out of order.
  • The system should tolerate high network latency and brief disconnects.

Cover the following in your answer:

  1. Architecture. How clients connect and receive live updates, which backend services exist, and which storage you use for document state and edit history.
  2. Data model. How you represent the document content and how you encode individual edits (inserts, deletes, and formatting changes).
  3. Concurrency control (the core). How concurrent edits are ordered or merged. Explain at least one approach in real depth: a server-assigned global sequence, Operational Transformation, or a CRDT. Show why replicas converge even when operations arrive out of order.
  4. Trade-offs. What consistency guarantees you offer, and how you keep latency low without forcing users to wait on each other.
  5. Scale and reliability. How the design handles millions of documents, hundreds of simultaneous editors on a single hot document, and server crashes without losing acknowledged edits.

Assume WebSockets (or a similar persistent connection) on the client side.

Hints

Hint 1

Decide which party owns the ordering of operations for a given document. If a single owner exists per document, you can avoid the hardest correctness problems.

Hint 2

Think about what a client needs to know about the revision an edit was written against. Without that, the server cannot tell how to shift positions when merging.

Hint 3

Walk through a concrete two-user example on paper: both users edit the same starting text, one edit lands first at the server, and check that both final states match.