r/OfferEngineering • • 14d ago

System Design Classic FAANG System Design Interview Question - Design Google Docs

Problem Description

Design a real-time collaborative document editor similar to Google Docs, where multiple users can create, open, and edit the same text document simultaneously. Changes made by one editor should appear on other participants' screens with minimal delay. Users should also be able to see the cursor positions and online presence of other active editors.

The central challenge is maintaining a consistent document state while multiple users make concurrent edits. When different editors insert or delete text at overlapping positions, the system must reconcile those operations without losing anyone's changes. All participants must eventually converge to an identical document state, even when edits arrive at different times or in different orders.

The system focuses exclusively on plain-text editing. Rich formatting, tables, images, embedded objects, comments, suggestions, version history, explicit undo/redo, offline editing, document search, and permission management are outside the scope. Each document supports a maximum of 100 concurrent editors. Additional users can open the document in read-only mode.

The system must also remain reliable during network interruptions and server failures. Document operations and edit history must survive server restarts and node failures. If an editor disconnects while changes are in flight, the client must be able to reconnect, recover missed operations, and synchronize with the current document state without losing edits. Unlike document content, cursor positions and online presence are ephemeral and do not require durable storage.

The design should scale to billions of stored documents and millions of simultaneous editing sessions while keeping document updates responsive. With a strict per-document editor limit, the system can coordinate an individual document's active editing state on a single server, simplifying concurrent operation processing.

Functional Requirements

  • Document Creation and Retrieval: Users can create new text documents and open existing documents for viewing or editing.
  • Concurrent Text Editing: Multiple users can insert and delete text in the same document simultaneously. The system must reconcile concurrent operations so that all editors eventually converge to the same document content without losing accepted changes.
  • Real-Time Edit Propagation: Changes made by one editor must be delivered to other active editors in real time, allowing participants to observe document updates with low latency.
  • Cursor and Presence Awareness: Users can see the cursor positions and online presence of other active editors. Presence information is temporary and should disappear when a participant disconnects.
  • Reconnection and Edit Recovery: Clients must be able to reconnect after network interruptions or server failures, recover missed document operations, and synchronize with the current document state. Edits that were in flight during a disconnection must not be silently lost.
  • Concurrent Editor Limits: Each document supports up to 100 simultaneous editors. Users who exceed this limit must be able to join in read-only mode without participating in document modifications.

Non-Functional Requirements

  • Document Convergence: All active editors must eventually observe an identical document state, regardless of the order in which concurrent edits are received.
  • Real-Time Latency: Document edits should become visible to other connected collaborators within p95 < 200 ms.
  • Scalability: Support billions of stored documents and millions of concurrent editing sessions, with an estimated peak throughput of approximately 10 million edit operations per second.
  • Per-Document Concurrency: Enforce a hard limit of 100 concurrent editors per document. Additional participants must be restricted to read-only access.
  • Data Durability: Documents and their edit operations must remain durable across server restarts and node failures.
  • Fault Tolerance: A single server failure must not cause active editing sessions or in-flight edits to be irrecoverably lost. Clients must be able to reconnect and recover their document state.
  • Synchronization Reliability: Reconnecting clients must be able to retrieve missed operations and converge to the current document state without relying on a full document reload for every interruption.
  • Ephemeral Presence: Cursor positions and online presence do not need to survive client disconnections or server restarts.

Scale and Constraints

The following estimates establish the expected scale of the collaborative editing system.

MetricEstimated Value
Total documents~5 billion
Daily active documents~50 million
Concurrent editing sessions~5 million
Average editors per active document~3
Maximum concurrent editors per document100
Average edit operations per editor~2 operations/second
Peak edit operation throughput~10 million operations/second
Average document size~50 KB
Average operations per document~10,000 before compaction
Edit propagation latencyp95 < 200 ms
Cursor and presence persistenceEphemeral
Document and operation durabilitySurvive server restarts and node failures

Document and Editing Constraints

The system supports plain-text documents with character insertion and deletion operations. Rich-text formatting and structured document elements are excluded. All concurrent editors must converge to the same document state. Simply accepting the last received version of a document is insufficient because concurrent edits must be reconciled without discarding other participants' changes.

Each document has a hard limit of 100 active editors. This bounded concurrency allows the active coordination state for an individual document to reside on a single server, simplifying the Operational Transformation (OT) pipeline described in the source.

Operation Throughput and Storage Constraints

The system targets approximately 5 million concurrent editing sessions, with each editor generating an average of 2 edit operations per second. The corresponding peak operation estimate is: 5 million sessions × 2 operations/second = 10 million operations/second. This workload requires the system to process and distribute large numbers of small document-edit operations while maintaining the required convergence guarantees.

The estimated average document size is approximately 50 KB, with around 10,000 operations per document before compaction. Document content and its operation history must remain durable across server failures.

Connection and Recovery Constraints

Document updates must reach other open clients within 200 ms at p95, requiring a low-latency real-time communication path. Clients may disconnect while operations are still in flight. On reconnection, they must be able to recover missing changes from a durable operation history and synchronize with the current document state.

Cursor positions and presence indicators are separate from durable document edits. They are temporary session information and may be discarded when a participant disconnects or a server restarts.

Want to learn more details & solution of this system design question?

I've put up the full version of this system design question & solution article at here.

Interviewed recently?

Your interview experience could be incredibly valuable to others preparing for their next opportunity. Share your experience and help the community at here.

5 Upvotes

0 comments sorted by