Lesson Overview + Section #01 + RESHADED Checklist + Quiz #1 are unlocked free below (no login required). Unlock all 80 HD video lessons and deep-dive sections — or watch our two free sample video lessons first.
Design a Collaborative Document Editing Service/Google Docs
A collaborative document editing service like Google Docs enables dozens of concurrent writers to type into the same rich-text document simultaneously with 0 ms perceived local latency and sub-250 ms remote convergence across 80 million daily active users (8 million peak WebSockets, 160 billion keystroke operations/day, 8 TB/day operation log). Whole-file saves silently overwrite peer edits, while pessimistic locks serialize writers into a queue; real-time co-editing requires streaming granular character/range mutations ordered consistently across replicas. L4-L6 interviewers evaluate optimistic local editing, single-server per-document ordering via consistent hashing, Operational Transformation (OT) vs. Conflict-Free Replicated Data Types (CRDTs), and event-sourced Snapshot + Operation Log compaction.
WHAT YOU WILL MASTER IN THIS LESSON
Size stateful WebSocket gateways (160 servers at 50K open sockets/host) and identify why the 8 TB/day operation log (8x larger than 1 TB/day new documents) mandates periodic snapshot compaction.
Design a dual-plane architecture pairing document-hashed stateful Collaboration Servers and replicated write-ahead queues with stateless HTTPS APIs backed by SQL (ACLs), NoSQL (comments), and Blob + CDN (media).
Resolve concurrent index-shift divergence ('CAT' -> 'HAT' vs. 'AHT') using server-serialized Operational Transformation (OT) and single-in-flight client operation buffering.
Compare centralized OT against decentralized sequence CRDTs across per-character memory overhead, tombstone garbage collection, offline merge resilience, and per-document active editor caps (~100).
Follow this exact sequence from the Intro narration on every system design prompt so you never miss requirements, math, contracts, or the 13-minute deep dive.
0 / 8 Checked
RRequirements & ScopeMin 2–8
Clarify who the users are, 3–4 core functional flows, explicit non-goals, and target latency/availability SLAs before drawing a single box.
Avoid trap: Still gathering requirements at minute 15 squeezes the deep dive where L5/L6 offers are decided.
EBack-of-the-Envelope MathMin 8–12
Compute ONLY numbers that actively change architectural choices: DAU → peak read/write RPS, daily & 5-year storage, bandwidth (or tokens/sec & KV-cache VRAM for AI).
Avoid trap: Spending 10 minutes multiplying irrelevant byte counts that never influence sharding or caching.
SStorage & Data ModelMin 12–15
Define core tables, primary/partition keys, and access indexes. Separate small structured metadata rows (~1 KB) from bulk binary blobs (S3 + CDN).
Avoid trap: Picking Cassandra or NoSQL by buzzword when 40 writes/s & 3 TB fit cleanly on one indexed SQL primary + replicas.
AAPIs & Wire ContractsMin 15–17
Write 3–4 concrete REST/gRPC/SSE/WebSocket endpoints with request/response shapes, cursor pagination, and Idempotency-Key headers on mutations.
Avoid trap: Hand-waving client-server contracts and discovering missing parameters halfway through the deep dive.
HHigh-Level DesignMin 17–27
Draw the simplest end-to-end working read and write paths first. Every box on the board must trace back to a stated requirement or number.
Avoid trap: Reciting a memorized 12-microservice Kafka mesh before proving why a simpler synchronous path breaks.
DDetailed Design (Deep Dive)Min 27–36
Proactively audit your high-level diagram, name the top 2 bottlenecks (hot partitions, fan-out skew, lock contention, GPU saturation), and go deep on internals.
Avoid trap: Waiting passively for the interviewer to rescue pacing or skimming every box at shallow surface depth.
EEvaluation & Failure ModesMin 36–41
State what each architectural choice COSTS you, and trace graceful degradation when cache, queue, external vendor, or primary DB fails.
Avoid trap: Assuming happy-path uptime or placing slow 3-second external calls inline on revenue-critical write paths.
DDistinctive FeatureMin 41–45
Solve the signature hard problem unique to this prompt (e.g., double-entry ledger idempotency, Geohash dispatch locks, OT/CRDT sync, or SSE token streaming).
Avoid trap: Spending 20 minutes on generic login/CRUD tables and zero time on the core distributed challenge.
INTERVIEWER SCORECARD · WHAT MAKES A STRONG HIRE?
5 Signals Bar Raisers Grade (L4 vs. L5 Senior vs. L6 Staff)
Senior (L5 / E5 / Senior SDE) Bar — Autonomous Pacing, Depth & Proactive Trade-Offs: Owns the 45-minute clock without prompting, derives every component quantitatively, surfaces failure modes (hot shards, stampedes, dual writes) BEFORE being asked, and defends consistency vs. latency trade-offs.
1. Scoping
✓ STRONG HIRE SIGNAL
Clarifies users, read/write skew, p99 latency, consistency bounds, and explicit non-goals in minutes 2–8.
✗ NO-HIRE RED FLAG
Jumps straight into drawing load balancers and microservices at minute 2 without asking a single question.
2. Right-Sized Design
✓ STRONG HIRE SIGNAL
Starts with the simplest working architecture justified by the math (e.g., 1 NVMe SQL primary + replicas + Redis for 40 writes/s & 3 TB).
✗ NO-HIRE RED FLAG
Recites a memorized Kafka + multi-DC Cassandra diagram that contradicts their own traffic calculations.
3. Technical Depth
✓ STRONG HIRE SIGNAL
Drives deep into 1–2 hard bottlenecks (partition keys, hot-key mitigation, transactional outbox, KV-cache batching) at minute 27.
✗ NO-HIRE RED FLAG
Skims across 12 boxes at identical buzzword depth and runs out of time before the deep dive.
4. Explicit Trade-Offs
✓ STRONG HIRE SIGNAL
Uses 3-part reasoning: 'A queue here because SMTP spikes to 3 s; checkout stays <60 ms, and we accept eventual email delay + retry dedup.'
✗ NO-HIRE RED FLAG
Name-drops tools ('We put Kafka and ZooKeeper here') without stating the alternative or operational cost.
5. Communication
✓ STRONG HIRE SIGNAL
Thinks aloud every 30–45s, checks alignment at phase transitions, and treats 'What if X fails?' as a cue for where points are awarded.
✗ NO-HIRE RED FLAG
Goes silent for 5 minutes while drawing or defends a flawed assumption defensively when nudged.
ARCHITECTURE & DATA-FLOW SLIDES · SLIDE 1 OF 1Section 01: System Design: Google Docs
ARCHITECTURE / DATA FLOW DIAGRAM
SECTION 01 OF 5
1. System Design: Google Docs
★ FREE PREVIEW
Key Takeaway: Whole-file uploads lose concurrent edits and exclusive locks block collaboration; real-time co-editing streams tiny character-level operations and converges by applying them under one agreed causal order.
ARCHITECTURE / DATA FLOW DIAGRAM
Why Whole-File Overwrites and Pessimistic Locks Fail
Allowing multiple authors to edit a shared document exposes an immediate concurrency dilemma. Under naive whole-file upload (Last Writer Wins), Alice downloads v1, appends a paragraph, and saves v2, while Bob—who also opened v1—fixes a single typo a minute later and uploads his full buffer, silently erasing Alice's paragraph. Pessimistic file locking prevents lost updates by granting exclusive write access to Alice while forcing Bob into read-only mode, turning five teammates racing a deadline into a sequential queue. Collaborative editors take a third path: every keystroke emits a compact delta operation (such as insert(pos=4, "H")), ordered centrally and broadcast within < 250 ms so all replicas converge on identical text.
Concurrency Model
Write Unit
Multi-Author UX
Primary Failure Mode
Last Writer Wins (Whole File)
Entire document blob
Concurrent offline/local edits
Silent data loss: later save overwrites peer changes
Pessimistic Exclusive Lock
Document-wide lease
1 active writer; N-1 blocked readers
Destroys live teamwork; orphaned locks on client crash
Granular Operation Streaming
Character/range op (~50 bytes)
Simultaneous sub-second live co-editing
Index shifts diverge unless transformed (OT) or ID-addressed (CRDT)
Three Core Ideas Behind Live Collaboration
Modern cloud editors rest on three tight architectural invariants: mutate the local browser copy immediately on keystroke so typing never waits on network RTT, route all operations for a given doc_id through a single authoritative ordering coordinator so every replica converges, and append every accepted operation to a replicated log backed by periodic full-document snapshots.
Edit Locally (0 ms UI latency): Local DOM updates occur synchronously before any network packet leaves the browser.
Order Centrally (1 coordinator per active doc_id): Eliminates distributed multi-leader transformation cycles.
Log Everything Durably (WAL + Snapshots): Guarantees zero acknowledged-edit loss and supports full version history.
SECTION 02 OF 5
2. Requirements of Google Docs' Design
🔒 PRO SECTION
Key Takeaway: With 80M DAU generating 160 billion operations/day (~1.85M ops/s), the 8 TB/day append-only operation log outgrows raw new document text (1 TB/day) by 8x, making periodic snapshot compaction essential.
Section 1 + Checkpoint Quiz #1 are unlocked free outside the paywall. Unlock all architecture slides, QPS & sharding trade-off tables, and all 80 narrated HD video lessons with Full Access — or inspect our sample payment system lesson first.
Key Takeaway: Route all real-time operations for a document via consistent hashing to a single Collaboration Server holding live state in RAM backed by a replicated write-ahead queue, while isolating ACLs in SQL, comments in NoSQL, and media in Blob Storage + CDN.
Section 1 + Checkpoint Quiz #1 are unlocked free outside the paywall. Unlock all architecture slides, QPS & sharding trade-off tables, and all 80 narrated HD video lessons with Full Access — or inspect our sample payment system lesson first.
Key Takeaway: Concurrent edits converge either by transforming positional indices against linear server history (OT, used by Google Docs for lean documents) or by assigning immutable per-character identifiers and tombstones that commute in any order (CRDTs).
Section 1 + Checkpoint Quiz #1 are unlocked free outside the paywall. Unlock all architecture slides, QPS & sharding trade-off tables, and all 80 narrated HD video lessons with Full Access — or inspect our sample payment system lesson first.
Key Takeaway: Optimistic local edits, single-server per-document serialization, and replicated write-ahead logging satisfy latency, convergence, and durability—at the intentional trade-off of capping concurrent active editors per document to ~100.
Section 1 + Checkpoint Quiz #1 are unlocked free outside the paywall. Unlock all architecture slides, QPS & sharding trade-off tables, and all 80 narrated HD video lessons with Full Access — or inspect our sample payment system lesson first.
In "System Design: Google Docs" (Why Whole-File Overwrites and Pessimistic Locks Fail), how does a production-grade design handle "Pessimistic Exclusive Lock" (Primary Failure Mode)?