Skip to content

Design a Collaborative Editor (Google Docs), stage 10 of 12: change it

The all-hands document

The single-owner design made ordering free. Now one document's traffic exceeds what one process can deliver. Sequencing is still cheap (200 ops/s); delivery is not (about 46,000 messages/s).

System so far· 4 parts
123CLIENTEditor 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
  3. 3Document owner → Postgres op log: Append ops at next seq (batched, epoch-fenced)
  • Server push
  • Request / response

What you need to know

0 of 2 checks done
  1. Find the part of the work that must be serialized and keep only that part serialized. Here:

    • Sequencing (assigning order) must be single-writer, and it's cheap: about 200 ops a second.
    • Delivery (sending to 230 sockets) is expensive, and parallel by nature.
  2. Work it out

    Instead of sending each op separately, each recipient gets one frame every 50 ms containing all new ops. With 230 recipients, how many frames a second?
    frames per second