Design a Collaborative Document Editor

HardReal-timeOperational TransformationCRDTsWebSocketsVersioningAbout 45 minutes

Design a collaborative editor like Google Docs: several people edit the same document at once and see each other's changes and cursors within a fraction of a second. Documents keep full version history. Plan for 10M daily users and up to 100 simultaneous editors per document.

How the interview goes

Five phases, and questions the interviewer is likely to ask in each.

  1. 1. Requirements

    • What must happen when two people edit the same word?
    • How far back must history go?
    Show a hint

    Ask what 'consistent' means when two people type at once.

  2. 2. High-level design

    • Where are edits ordered?
    • What is durable and what is ephemeral?
    Show a hint

    Edits to one document need a single ordering, or a way to merge without one.

  3. 3. Deep dive

    • Walk me through two concurrent inserts at the same index.
    • How does a client that was offline catch up?
    Show a hint

    Concurrent operations can be adjusted against each other before applying.

  4. 4. Scaling

    • What if one document has 1,000 viewers?
    • How do you rebalance documents across servers?
    Show a hint

    Replaying every edit from the beginning will not scale.

  5. 5. Trade-offs

    • OT versus CRDT?
    • Server-ordered versus peer-to-peer?
    Show a hint

    A central server makes ordering easy but adds a dependency.

Practice this with an AI interviewer

Write your design doc with live diagrams while the interviewer asks one question at a time and pushes on your choices. Get a scored debrief with what to study next.

Start this interview