Skip to content

Design a Collaborative Editor (Google Docs), stage 2 of 12: decide

Choose the transport

Each active editor streams 5-10 small operations a second to the server and receives everyone else's from it, ideally within 200 ms. Order matters: an editor's operations depend on the ones before them.

System so far· 2 parts
CLIENTEditor clientDATABASEPostgres op log

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

What you need to know

0 of 1 checks done
  1. Transports differ in direction, overhead and ordering:

    TransportDirectionOrdering of one client's messages
    Pollingclient askseach request separate
    Server-Sent Eventsserver → clientordered downstream only
    HTTP POST per opclient → serverseparate requests can arrive out of order
    WebSocketboth ways, one connectionordered both ways

    See Server push: polling, long polling, SSE, WebSockets and Persistent connections.

  2. Check

    Each keystroke is a separate POST. Op 2 is sent before op 3, but op 3's request arrives first. What must the server do?