Loading...
Loading...
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.
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.
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.