KatInterview

Build a Multi-User Live Text Editor Backend

System DesignModel answer
MediumModel answerSystem Designsystem-designreal-timecrdt

Last updated

Design a backend that lets many people edit one document at once with fast sync, offline tolerance, durable storage, and version history.

Build a Multi-User Live Text Editor Backend

Design the backend for a shared document editor in the spirit of a web-based office suite or a notes app. Several people open the same document, type at the same moment, and each of them must end up looking at an identical document.

What the system must do

  1. Keep the content of every participant in sync in near real time, at the level of characters or blocks.
  2. Store documents durably so nothing acknowledged is ever lost.
  3. Resolve edits that happen at the same time, with clearly defined behavior.
  4. Let users browse earlier versions and roll back to one of them.

Quality targets

  • Latency: an edit made by one person shows up for the others in under 200 ms.
  • Resilience: if a user's connection drops briefly, they can keep typing and nothing is lost when the connection returns.
  • Scale: thousands of documents are open at once. Most have a few editors, a few are very busy.

What your answer should cover

  • The overall architecture and which transport protocol you pick, and why.
  • The data model for documents, operations, snapshots and versions.
  • The synchronization approach (for example Operational Transformation versus CRDTs) and the reasons for your choice.
  • Persistence, conflict handling and version history.
  • What happens when a client goes offline and later comes back.

State your assumptions about scale with numbers, and point out the trade-offs you are making.

Hints

Hint 1

Begin by estimating load: how many operations per second, how large each one is, and how fast the log grows. These numbers justify batching, snapshots and compaction.

Hint 2

Give each document a single authoritative owner (for example through a lease plus consistent hashing). That gives you a total order of operations without distributed locking on the hot path.

Hint 3

Compare OT and CRDTs on offline support, metadata overhead, and implementation risk. Whichever you choose, spell out the rule for concurrent inserts at the same spot and for delete versus insert.

Hint 4

Think about reconnects: how does a client resend un-acknowledged edits safely, and how does the server avoid applying them twice?