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
- Type: each edit is sent over an open connection.
- Merge: edits are ordered in a log and applied to the document.
What you'll build
- The API and the data behind it
- Realtime gateways for open connections
- A log (stream) of edits with workers that apply them
- Shards for write-heavy scale
- A design that survives a cold cache and a lost gateway
Steps
- 1Design the API
- 2Design the data model
- 3Handle 1,000 requests/sec
- 4Handle 15,000 requests/sec for $1,500 a month
- 5Handle 40,000 requests/sec
- 6Handle 80,000 requests/sec
- 7Survive a bot flooding the editor
- 8Survive a cache restart
- 9Lose a realtime gateway
- 10Two people edit the same word
- 11Deep dive: opening a long document