Design Google Docs from an empty canvas: many people typing in the same document, every keystroke merged, logged and shown to the others within 100 ms.
Unlock it once for 25 credits; everything inside it is free (runs, changes, Submit, results, hints). Sign in with Google to start; new accounts get free credits.
What it must do
Several people edit the same document at once and see each other’s changes within a blink.
Concurrent edits merge into one consistent document (operational transform or CRDT), in one order per document.
Every operation is kept in the document’s log; opening a document loads its latest snapshot plus the operations since.
Show who is in the document and where their cursors are.
Scale
2,000 messages a second over WebSockets: 1,000 edit operations, 800 cursor and presence updates, 200 document opens.
About 50,000 people editing at once, a handful per document; a busy document sees an operation every 100 ms.
About 2.6 billion operations a month at ~200 bytes each go into the operation log.
Request types to route: edit (50%, write), presence (40%, write), open (10%, read). Budget: $8,000 a month.
Estimate first
Operations written to the log a day (million)
Operation log growth a month at 200 bytes an operation (GB)
Edit operations a second at the Monday-morning peak (3×) (ops/s)
Monthly cloud cost of your design (USD)
The test cases
You start from an empty canvas. When you run the tests, each one simulates your design with its own traffic and failures:
Test
What it does
Passes when
Normal day
The normal day: the traffic in the brief, nothing broken.
Success ≥ 99.9%; p99 latency ≤ 100 ms (edit); p99 latency ≤ 400 ms (open)
Monday, 9 am
At 5 s everyone opens their documents and starts typing: traffic triples for 8 s.
Success ≥ 99%; p99 latency ≤ 250 ms (edit)
A server dies
At 4 s one server of the first app service on the request path dies for 10 s.
Success ≥ 99%; p99 latency ≤ 250 ms (edit)
Database 5× slower
At 5 s the main database on the request path answers 5× slower for 8 s.
Success ≥ 99%; p99 latency ≤ 150 ms (edit)
Budget: $8,000/month
The normal day's design must cost at most $8,000 a month.
Cost ≤ $8,000/month
Must include
Persistent connections. Editors keep a WebSocket open so operations and cursors flow both ways without a new request each time.
A collaboration service per document. One owner per document orders and transforms concurrent operations so every editor converges on the same text.
An operation log. Every operation is appended durably before it is acknowledged, so nothing typed is ever lost.
Presence. Cursors and “who is here” are frequent, tiny and disposable: keep them in memory, away from the log.