Layer 3 · Go deeper · 11 min
Go deeper
Size it, build it, then make the calls an interviewer will push you on.
Back of the envelope
Size it up
Tap through each step of the arithmetic.
How much CPU does the busiest document need?
How much presence traffic, compared with edits?
How much op log does history add every day?
Build-up · 5 steps
Build the high-level design
One functional requirement at a time, ending with an editor that works in one region at modest traffic.
Step 1 of 5
Create and open documents
Creating is a metadata row plus an empty snapshot at revision 0. Opening checks your role, loads the nearest snapshot and replays the ops after it, so no open replays more than 1,000 ops.
6 interview moments
You’re the candidate
The interviewer pushes on the hard parts. Pick an approach and see how it holds up.
Deep dive 1 of 6
Interviewer
“Asha and Ravi edit “IPL FINAL” at once, and you run servers anyway for access, storage and search. How do you merge their edits?”
Your move. Pick an approach:
Deep dive 2 of 6
Interviewer
“You run 200 session servers, deploy daily, and machines sometimes pause. How does every editor of a document reach the one server that orders it?”
Your move. Pick an approach:
Deep dive 3 of 6
Interviewer
“Every acknowledged keystroke must survive, history goes back years, and old documents must still open fast. How do you store documents?”
Your move. Pick an approach:
Deep dive 4 of 6
Interviewer
“Presence is about four times the op traffic, and worthless a second later. How do you show live cursors?”
Your move. Pick an approach:
Deep dive 5 of 6
Interviewer
“Ravi’s Mumbai local enters a tunnel, or he edits offline on a flight. How do his edits rejoin the document?”
His in-flight op and buffer are saved in IndexedDB with their base revision, so even closing the tab loses nothing.
Your move. Pick an approach:
Deep dive 6 of 6
Interviewer
“An IPL live blog has 5 editors making about 20 ops a second, and 20,000 readers. How do the readers see it live?”
Your move. Pick an approach:
Build-up · 7 steps
Follow one edit to 20,000 readers
The live path is gateway → owner → op log. Everything else either prepares it, opening and ownership, or follows it, snapshots and viewers.
Step 1 of 7
Open
Asha opens the live blog. The doc service checks her role in the metadata DB and returns the latest revision, nearest snapshot plus a short replay, with a session token.