Design the architecture for Google Docs - the world's most popular collaborative document editor with over 1 billion users. Multiple users can edit the same document simultaneously and see each other's changes in real time. Your design must cover:
- Real-time collaborative editing - multiple cursors, real-time character-by-character updates visible to all editors within 100 ms. The system must handle up to 100 concurrent editors on a single document.•Conflict resolution - when two users type at the same position simultaneously, the system must merge changes without losing either edit. Implement Operational Transformation (OT) or CRDTs for deterministic conflict resolution.•Document storage - documents are stored as structured data (not flat text) supporting rich formatting (bold, italic, headers, tables, images). Autosave every few seconds.•Version history - full revision history with the ability to view, compare, and restore any previous version. Track who made each change and when (like git blame).•Comments & suggestions - inline comments anchored to text ranges, suggestion mode (track changes), and threaded discussions.•Access control - owner, editor, commenter, and viewer roles. Share via link or email invitation. Organization-wide sharing policies.•Offline editing - users can edit documents offline. Changes sync and merge when connectivity is restored.•Real-time cursors & presence - see other editors' cursor positions, selections, and avatars in real time.
The core challenge is implementing a real-time collaboration engine that maintains consistency across distributed clients with low latency.
Design Google Docs - real-time collaborative editing, conflict resolution, version history, and offline support for 1 B+ users. Build this architecture under realistic production constraints, then validate tradeoffs in the design lab simulation.
Request path: The solution keeps ingress, service logic, and stateful dependencies separated so each layer can scale independently.
Reference flow: Web Clients -> Load Balancer -> API Gateway -> Core Service -> Auth Service -> Primary NoSQL DB -> Replica SQL DB -> Realtime Bus