Design a Collaborative Editor
System Design Cases: lesson 20 of 20
Both typing in one paragraph, both landing on the same text.
Lesson 20 of 20 · 7 min
Design a Collaborative Editor
Step 1 of 11
Both people are inside the same paragraph, and both expect their own keystroke immediately.
The Idea
Two people typing in the same paragraph, each seeing their own keystroke instantly, both ending on identical text. The edit is applied locally first, then reconciled with whatever arrived from the other side.
Real-World Example
Two editors marking up one page by describing where each mark goes. "After the word cost" survives somebody inserting a sentence above it; "at character 41" does not.
The Tradeoff
Describing an edit by position means every concurrent edit must be transformed against it, which puts the ordering burden on a server that has to see everything. Identity-based edits merge in any order and carry metadata for every character ever typed. Presence rides a separate channel, because a moving cursor is not worth storing.
Your turn
Put the steps in the right order.
- Broadcast the settled edit to everyone else in the document
- Apply the keystroke locally and show it immediately
- Transform it against edits that arrived in the meantime
- Send the edit with the version it was written against
Mini quiz
1 / 3