Same Doc Same Time

Design a collaborative document editor where many people edit the same document at the same time and every editor ends up seeing the same result.

Requirements

Functional:

  • Many cursors in one document, with live remote cursors and selections.
  • Concurrent edits merge without losing work and without locking a paragraph.
  • Presence: who is in this document right now, and where they are.
  • A client can lose the network for up to an hour, keep editing, and reconcile on reconnect.
  • Version history: automatic snapshots plus user-named versions, and restore.

Non-functional:

  • Local typing latency is zero. A remote keystroke shows up within 150 ms p95 in the same region, 400 ms p95 cross region.
  • Presence updates within 1 second.
  • No divergence: two clients that have received the same set of edits must render identical documents.
  • An acknowledged edit survives the loss of any single instance.

Scale

  • 25M DAU, about 2M concurrent editor connections at peak.
  • Average editing session 18 minutes.
  • Clients batch keystrokes into one update every 100 ms, roughly 80 bytes of binary payload each, about 1M inbound updates per second at peak.
  • 4B documents, 20 KB median, 2 MB p99, growing 30M new documents per week.
  • The raw operation log would be roughly 7 TB per day before compaction.
  • A typical document has 3 concurrent editors. The worst has 50 editors and 5,000 read-only viewers.

Out of scope

Rich text rendering internals, comment threads and their notifications, export to PDF or DOCX, cross-document full-text search, and mobile app packaging.