Skip to content

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
12CLIENTEditor clientEDGEDocument routerSERVICEDocument ownerDATABASEPostgres op log

Select a component to see what it is responsible for and which state it owns.

  1. 1Editor client → Document router: WebSocket: ops, acks, remote ops, presence
  2. 2Document router → Document owner: Route by document id to the current owner

What you need to know

0 of 2 checks done
  1. 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.

  2. Check

    Why does Alice's client apply her keystroke locally before the server has seen it?