Skip to content
SD-37 · System design

Design a Collaborative Documents

Asked at Mid level45 minutes
Our answers stay hidden until you reveal them.

Design a document service like a team wiki or a shared document editor. People create pages, organize them in folders, share them with people or groups, and edit them together in real time: each person sees the others’ typing and cursors as it happens. Every document keeps a version history that can be browsed and restored, and pages can be found by searching their text.

The service has 10 million daily users and a billion stored documents, and at peak 1.5 million people have a document open at once. The hard part is concurrent editing: two people typing in the same sentence must both keep their work, every copy must end up identical, typing must feel instant, and a confirmed keystroke must never be lost, even when the server holding the document crashes.

Good questions to ask first

Decide what you would assume for each before you look at ours.

  1. 1How many people edit at once?
  2. 2Rich text or plain text?
  3. 3Must edits from others appear live?
  4. 4Offline editing?
  5. 5How long is history kept?
  6. 6Who can see a document?
  7. 7How big can a document be?
  8. 8Do we need search?

How to spend the 45 minutes

  1. 5minPart 1: Requirements and scope
  2. 5minPart 2: Estimates
  3. 5minPart 3: API and the live protocol
  4. 15minPart 4: Architecture, stage by stage
  5. 15minPart 5: Merging, ownership and failures
Sketch your own design: boxes, arrows and the numbers that matter. Then compare it with ours.Break it in the labVisual walkthrough