KatInterview

Build a Multi-User Live Text Editing Platform

System DesignModel answer
MediumModel answerSystem Designsystem-designreal-timeoperational-transformation

Last updated

Design a service where many people edit one document at once, see each other's changes quickly, keep history, show live cursors, and can work offline, all while converging to one state.

Problem

Design the backend and client sync strategy for a web-based rich-text editor in which several people work on the same document simultaneously. Walk through requirements, rough capacity numbers, architecture, and the hardest technical pieces. Plan for about 40 minutes of discussion.

What the product must do

  • Many users can edit one document at the same moment.
  • Other people's changes show up within roughly 1-2 seconds, ideally well under 500 ms.
  • If two people touch the same region, the system merges their work sensibly instead of failing or discarding either edit.
  • Users can browse earlier versions of a document and restore one.
  • Users can see who else is present, where their cursors are, and what text they have selected.
  • Users can keep editing while offline, and their changes merge in on reconnect.

Quality targets

  • Up to 100 simultaneous editors in a single document.
  • Remote edits visible in under 500 ms in the common case.
  • Strong eventual consistency: clients may briefly differ but must always converge to an identical document.
  • No loss of acknowledged edits.

Scale assumptions

  • Around 2 million concurrent editing sessions at peak, each producing about 40 operations per minute.
  • Each operation is small, roughly 50-200 bytes.
  • About 500 million documents, averaging 50 KB each.

What to cover

  1. Clarify scope and derive capacity numbers from the assumptions above.
  2. Define the client/server API and the data model.
  3. Draw the high-level architecture and explain how editors of one document are routed.
  4. Explain how concurrent edits are reconciled, and compare operational transformation (OT) with CRDTs.
  5. Describe the client-server sync protocol, including optimistic local edits.
  6. Cover durability, failover, version history, presence, and offline reconciliation.
  7. Name the main trade-offs and likely failure modes.

Hints

Hint 1

Compute the load first: 2M sessions x 40 ops/min is about 1.3M ops/s. Notice it is many tiny messages rather than heavy bandwidth, and that work can be partitioned per document.

Hint 2

If every editor of a given document is routed to a single server that assigns a global order to operations, the conflict-resolution problem becomes much simpler. Think about how that affects what properties your transform function needs.

Hint 3

Treat ephemeral data (cursors, who is online) differently from durable data (operations, snapshots). Ask what must survive a crash, when you may acknowledge an edit, and how a reconnecting client proves which edits it already sent.