Design Google Docs
Understanding the Problem
📝 What is Google Docs? Google Docs is a browser-based word processor where many people can edit the same document at the same time. Every keystroke shows up on everyone else's screen within a fraction of a second, along with their cursors and selections. There's no "save" button: every change is persisted as it happens, and the full edit history can be browsed and restored.
You'll also hear this asked as "design OneNote" or "design Google Keep sync." Those products lean harder on offline use (you edit a note on a plane, your laptop edits the same note at home, and both have to merge later), but underneath it's the same problem: several replicas of one document change independently and must converge to the same content without losing anyone's work. We'll design the real-time editor first and treat offline sync as a deep dive.
Functional Requirements
We'll agree with our interviewer on what the editor needs to do. Docs has a huge feature surface (comments, suggestions, tables, add-ons), so we'll be explicit about scoping it down to the collaboration core.
Core Requirements
- Users should be able to create a document and open an existing one.
- Users should be able to edit a document at the same time as other users and see each other's changes in real time.
- Users should be able to see who else is in the document and where their cursors are.
- Users should be able to browse a document's version history and restore an older version.
Below the line (out of scope)
- Sharing and permissions. We'll assume an authorization service answers "can user U edit doc D?" (see
/system-design/authorization-service). - Comments, suggestion mode and rich layout features (tables, images, page breaks).
- File storage and folder organization, which belongs to
/system-design/google-drive.
Non-Functional Requirements
Ask your interviewer about scale and limits. We'll assume 1 billion documents, 100M daily active users, and at peak about 10M documents open at once. Like real editors, we'll cap a single document at 100 simultaneous editors; anyone beyond that joins read-only.
Core Requirements
- All collaborators must converge to the same document content, no matter what order their edits arrive in.
- Edits should appear on other collaborators' screens within ~200 ms at p95 in the same region.
- An edit that the server has acknowledged must never be lost, even if a server crashes.
- Typing must feel instant. Local edits apply immediately and never wait for the network.
- Users should be able to keep editing through short disconnects (and, for the Keep/OneNote variant, long offline periods).
Below the line (out of scope)
- Multi-region active-active editing of a single document. A document lives in one region at a time.
- Full-text search across documents.
Some quick math. Say 2M of those open documents have someone actively typing at a given moment, and the client batches keystrokes into one message every ~200–500 ms. That's roughly 4M operations per second at peak. At ~100 bytes per operation, it's about 400 MB/s of edits coming in. Averaged over a day (call it a third of peak), that's around 115 billion operations and on the order of 10 TB of raw edit log per day.
That sounds frightening until you look at it per document: 100 editors × a few ops per second is at most a few hundred ops per second for the busiest document, and most documents see one or two. The total load is huge, but it's made of millions of tiny, independent streams.
The insight that shapes the design: the work partitions perfectly by document. Nothing about editing doc A needs to know about doc B. So instead of building one giant system that orders 4M ops/s, we build something that orders a few hundred ops/s per document and runs millions of those side by side.