ProblemReal-time and messaging
Collaborative document editor
Many people edit the same document at once, and everyone ends up seeing the same text.
The brief
Document editor · suggested for Senior
Design Google Docs
Design a collaborative document editor like Google Docs: many people edit the same document at the same time, each sees their own typing instantly and everyone else's within a fraction of a second, and every screen ends up with the same text.
A company is building a document editor for teams. Several people open the same document and type at once; each sees their own typing immediately and the others' a moment later, along with who else is in the document and where their cursors are. Documents are shared with named people or by link, as viewer, commenter or editor, and owners can take access away at any time. People comment on passages, look back through a document's history and restore an earlier version, and keep editing on a train when the connection drops. Most documents have one to three editors at a time, but a company-wide meeting can put thousands of readers and dozens of editors on one document. Machines fail every day at this size. Design the editor, from a keystroke to the same text on every screen.
Functional requirements
- CoreCreate a document and share it with people or by link, as viewer, commenter or editor.
- CoreSeveral people edit the same document at once: each sees their own typing instantly and everyone else's within a fraction of a second.
- CoreSee who else is in the document and where their cursors are.
- CoreComment on a passage of text.
- CoreSee a document's version history and restore an earlier version.
- CoreKeep editing through a lost connection, for up to about a day, and have the edits merged on reconnect.
Non-functional requirements
- ConsistencyNo edit is lost: when two people change the same passage at the same moment, both changes survive, and everyone ends up with exactly the same text.
- LatencyYour own typing shows at once, and other people's edits appear within about 200 ms at p99.
- DurabilityAn edit the editor has shown as saved survives any server crash.
- LatencyAny document, however old, opens in about a second.
- SecurityRemoving someone's access takes effect at once, even if they have the document open.
- AvailabilityEditing keeps working when a server, or a whole region, fails.
- QualityA busy document with thousands of readers and dozens of editors stays live for all of them.
- CostServers and storage are the main costs; idle documents should cost little.
Scale
- ScaleAbout 50 million daily users and about 1 billion documents.
- ScaleAbout 2 million documents open for editing at peak, over about 5 million live connections.
- ScaleAbout 300,000 edits a second at peak (typing, deleting, formatting).
- ScaleMost documents have 1–3 editors at once; a busy document can have about 5,000 readers and about 100 editors.
- ScaleDocuments run up to a few hundred pages; version history is kept for their whole life.
Nice to mention (below the line)
- Below the lineImages, tables and drawings (treat them as objects inside the text).
- Below the lineSuggestion mode.
- Below the lineSpreadsheets and slides.
- Below the lineSearch across documents.
- Below the lineExport to other formats.
Out of scope
- Out of scopeSign-in and accounts.
- Out of scopeBilling.
- Out of scopeSpell-check, grammar and AI writing features.
The variant
One fully specified brief, with the level it suits best. You can practise it at any level.
- Document editorSuggested for Senior
A Google Docs–style editor: many people type in one document at once and all see the same text, with cursors, comments, sharing by role or link, offline editing and version history.
9 steps · 6 must-pass · about 51 min at Senior
What each level is graded on
Document editor, step by step. A result at a level needs its must-pass steps answered, and only the steps you answer count. Going up a level adds steps or holds them to a stricter bar.
| Step | Entry level | Mid-level | Your levelSenior | Staff |
|---|---|---|---|---|
| The numbers that shape the editor (optional) | Graded | Graded | Graded | Graded |
| Documents, sharing and comments | Graded | Graded | Graded | Graded |
| Opening, editing and sharing | Graded | Graded | Graded | Graded |
| From a keystroke to everyone's screen | Must-pass | Must-pass | Must-pass | Must-pass |
| Two people, one sentence | Must-passcan block | Must-passcan block | Must-passcan block | Must-passcan block |
| Nothing typed is lost | Must-pass | Must-pass | Must-pass | Must-pass |
| Offline on a train | — | Must-pass | Must-pass | Must-pass |
| Sharing, and taking it back | — | Must-pass | Must-pass | Must-pass |
| The all-hands doc | — | — | Must-pass | Must-pass |
| A billion documents, three regions | — | — | — | Must-pass |
| At this level | 6 steps 3 must-pass about 33 min | 8 steps 5 must-pass about 44 min | 9 steps 6 must-pass about 51 min | 10 steps 7 must-pass about 59 min |
Entry level6 steps · 3 must-pass · about 33 min
- The numbers that shape the editor (optional)Graded
- Documents, sharing and commentsGraded
- Opening, editing and sharingGraded
- From a keystroke to everyone's screenMust-pass
- Two people, one sentenceMust-passcan block
- Nothing typed is lostMust-pass
Mid-level8 steps · 5 must-pass · about 44 min
- The numbers that shape the editor (optional)Graded
- Documents, sharing and commentsGraded
- Opening, editing and sharingGraded
- From a keystroke to everyone's screenMust-pass
- Two people, one sentenceMust-passcan block
- Nothing typed is lostMust-pass
- Offline on a trainMust-pass
- Sharing, and taking it backMust-pass
SeniorYour level9 steps · 6 must-pass · about 51 min
- The numbers that shape the editor (optional)Graded
- Documents, sharing and commentsGraded
- Opening, editing and sharingGraded
- From a keystroke to everyone's screenMust-pass
- Two people, one sentenceMust-passcan block
- Nothing typed is lostMust-pass
- Offline on a trainMust-pass
- Sharing, and taking it backMust-pass
- The all-hands docMust-pass
Staff10 steps · 7 must-pass · about 59 min
- The numbers that shape the editor (optional)Graded
- Documents, sharing and commentsGraded
- Opening, editing and sharingGraded
- From a keystroke to everyone's screenMust-pass
- Two people, one sentenceMust-passcan block
- Nothing typed is lostMust-pass
- Offline on a trainMust-pass
- Sharing, and taking it backMust-pass
- The all-hands docMust-pass
- A billion documents, three regionsMust-pass
- Must-pass
- a result at that level needs this step answered.
- Can block
- a miss there is a Blocking issue at that level.
Going up a level
- Mid-level
- “From a keystroke to everyone's screen” is graded more strictly.“Nothing typed is lost” is graded more strictly.Adds “Offline on a train”, must-pass.Adds “Sharing, and taking it back”, must-pass.
- Senior
- “Offline on a train” is graded more strictly.“Sharing, and taking it back” is graded more strictly.Adds “The all-hands doc”, must-pass.
- Staff
- Adds “A billion documents, three regions”, must-pass.
Skills this problem practises
Your coach tracks readiness per skill across every problem you practise. Each links to the lesson that teaches it.
- Capacity estimation
- API design
- Idempotency and retries
- Data modelling
- Choosing storage
- Sharding and partitioning
- High-level architecture
- Networking and protocols
- Traffic surges and backpressure
- Consistency and concurrency
- Replication and durability
- Observability and operations
Worked solution
Try it first: practise a variant, then read the walkthrough and compare it with your own design. Reading it first makes the practice much less useful.
Learn: Design Google DocsYour history
Sign in to see your sessions on this problem.