failover
← All labs

Hard · 11 steps · ~75 min

Design a collaborative editor

Many people typing in one document, and nobody's edit lost.

Edits from many people must reach everyone quickly and merge without losing anyone's work. Every keystroke is a tiny write.

Same problem as Google DocsNotionFigma

How it works

What you'll build

  1. The API and the data behind it
  2. Realtime gateways for open connections
  3. A log (stream) of edits with workers that apply them
  4. Shards for write-heavy scale
  5. A design that survives a cold cache and a lost gateway

Steps

  1. 1Design the API
  2. 2Design the data model
  3. 3Handle 1,000 requests/sec
  4. 4Handle 15,000 requests/sec for $1,500 a month
  5. 5Handle 40,000 requests/sec
  6. 6Handle 80,000 requests/sec
  7. 7Survive a bot flooding the editor
  8. 8Survive a cache restart
  9. 9Lose a realtime gateway
  10. 10Two people edit the same word
  11. 11Deep dive: opening a long document
Start the lab →