KatInterview

Design a Real-Time Collaborative Spreadsheet Service

System DesignModel answer
HardModel answerSystem Designreal-timecollaborative editingconflict resolution

Last updated

Design a multi-user spreadsheet system where concurrent editors stay in sync, conflicts resolve correctly, and clients recover cleanly after disconnects.

The Problem

You're designing a cloud spreadsheet product — think of any tool where multiple people can edit the same grid simultaneously and see each other's changes in real time.

A workbook contains one or more sheets. Each sheet is a grid of cells that can hold raw values, formulas, or formatting. Any number of authenticated users can have the same workbook open at once, and edits from one user should appear on everyone else's screen within a fraction of a second.

What the system must support

  • Create, open, and manage workbooks with multiple named sheets.
  • Edit cell contents (values, formulas, formatting), and insert, delete, or reorder rows and columns.
  • All clients editing concurrently converge to an identical final state — no silent divergence.
  • Show live presence: where other users' cursors and selections are.
  • Handle disconnects gracefully: a client that drops offline and reconnects should catch up on missed changes without losing its own pending edits.
  • Maintain a version history with the ability to restore a prior state.

What the interviewer wants to see

Walk through your design end-to-end:

  1. Requirements — functional and non-functional, with rough scale estimates.
  2. API design — concrete endpoints and WebSocket messages, including the important request parameters and what they protect against.
  3. Data model — workbooks, sheets, cells, the operation log, and snapshots.
  4. Architecture — which services exist, how sessions are established, and how edits flow from client to all other clients.
  5. Conflict resolution — how two simultaneous edits to the same or related cells are handled correctly and deterministically.
  6. Row and column operations — why inserting a row mid-sheet is harder than it looks and how to solve it.
  7. Formula recalculation — where computation happens, what data structure drives it, and how cycles are caught.
  8. Persistence and recovery — durability guarantees, snapshotting strategy, and how a fresh server reloads a workbook.
  9. Scaling and observability — how the system handles hot workbooks, regional traffic, and failure of a document server.

Concrete trade-offs are expected throughout. Vague answers ("use a message queue") without justifying the choice are not enough.

Hints

Hint 1

Before anything else, nail down what 'consistent' means here. All clients must reach the same state at the same revision — not just eventually similar. That constraint drives almost every architectural choice downstream.

Hint 2

Rows and columns need stable internal IDs, not position indices. If you model a cell as (row 7, col 3) you'll spend the rest of the design fighting index-shift bugs in every concurrent-insert scenario. Make this decision early and explain why it simplifies your transform rules.

Hint 3

A central sequencer per workbook is the practical choice for conflict resolution. It gives you a total order of operations for free, which makes OT transforms straightforward, history trivial, and formula evaluation deterministic. Mention CRDTs and explain honestly why they're a worse fit here despite being fashionable.