Design a Collaborative Editor (Google Docs), stage 5 of 12: model
Trace one keystroke
Alice types a character. Follow the operation from her keyboard to Bob's screen. Getting the order right is what makes "no acknowledged edit is lost" true.
System so far· 4 parts
Select a component to see what it is responsible for and which state it owns.
- 1Editor client → Document router: WebSocket: ops, acks, remote ops, presence
- 2Document router → Document owner: Route by document id to the current owner
What you need to know
0 of 2 checks done
Custody: at every moment, an edit must be held by someone who won't forget it: either the client's pending buffer (saved locally for offline use) or the durable log on the server.
The acknowledgement hands custody over. So the server may only ack once the log has the edit, and the client may only drop the edit from its buffer once it has the ack. See Durability.
Check
Why does Alice's client apply her keystroke locally before the server has seen it?Think first
Alice never sees the ack for op a:812 and resends it. How does the owner avoid applying it twice?