Realtime collaboration series · Start here
Realtime collaboration & sync
Have you ever finished an edit, hit save, and later found it gone because a teammate saved over you? Or watched a shared board freeze, then jump, the moment the Wi-Fi dropped? Every app that lets people work together has to solve these problems. This series shows how.
- The problem: a plain “load, edit, save” app loses work when two people edit at once. Version checks and locks fix that, but make people wait or redo their work. Realtime sync is for when nobody should have to wait.
- Going live: realtime sync removes the waiting, but brings five new problems with it. Each article in this series takes one of them, from the symptom to working code.
1What goes wrong with “load, edit, save”
Most apps start with a simple model: load the data, let the user edit it, save it back. That works for one person. With two, it breaks in a way nobody notices until work is gone. This is the lost update problem.
This exact bug has a classic fix that needs no realtime at all. Give every record a version number. A save says “I edited version 1”; if the server already has version 2, it rejects the save and asks the user to reload. This is called optimistic locking, and many good apps stop right there. So why go further?
2Do you even need realtime?
There are four common ways to let several people edit the same thing, from simplest to most involved. Here is what Alice and Bob actually see on screen under each one.
1Save + spinner
Everyone waits on every save, and nobody sees the others until they reload.
2Version check
No work is silently lost, but whoever saves second has to redo it.
3Lock the file
Safe and simple, but only one person can work at a time.
4Realtime sync
Both work at once and see each other’s changes as they happen.
The simpler approaches are not wrong. Each one is the right answer for some products:
| Approach | Enough when | Breaks down when | You see it in |
|---|---|---|---|
| Save + spinner | Edits are occasional and fit in a form | Actions are continuous, like dragging or typing, or others need to see them | Settings pages, admin panels |
| Version check | Two people rarely edit the same record, and redoing is cheap | Many people edit the same thing at once, so rejections pile up | Wiki “edit conflict” pages, APIs with ETag / If-Match |
| Lock | One person edits at a time and taking turns feels natural | Working together is the point, or someone forgets to unlock | SharePoint check-out, WordPress post locks, Git LFS file locks |
| Realtime sync | Several people work in the same place at the same time, every action must feel instant, and seeing each other matters | It is overkill for forms and turn-taking, and it costs real engineering effort (the rest of this series) | Google Docs, Figma, Miro, multiplayer games |
3Where you meet these problems
Any product where people edit together runs into them. What changes is the shape of the data and how often two people touch the same piece of it.
| Use case | What has to stay in sync | How often people collide |
|---|---|---|
| Shared documents | A long stream of characters | Often: people type in the same paragraph |
| Spreadsheets | Cells and formulas | Sometimes: the same cell or a dependent one |
| Whiteboards & design tools | A tree of objects with properties | Rarely: people spread out across the board |
| Task trackers | Records with fields (status, owner) | Sometimes: two people move the same card |
| Chat & comments | An append-only list of messages | Almost never: messages are added, not changed |
| Multiplayer games | Game state, many times per second | Constantly, and every millisecond counts |
4Problems you may have
Going live removes the waiting, but it brings five new problems with it. Each article takes one, from the symptom you see to working code.
Changes take seconds to show up
You edit, and teammates only see it after a refresh, or a few seconds later.
How to push every change to everyone the moment it happens, instead of asking the server again and again.
- WebSocket realtime channel
- Room-based broadcast fan-out
Edits get lost, doubled or out of order
The Wi-Fi blips or a laptop sleeps, and some edits vanish or show up twice.
How to make every edit arrive exactly once and in order, even after going offline.
- Reliable ordered delivery
- Retransmission on gap
- Heartbeat & automatic reconnect
- Offline-first outbox
- Message replay on reconnect
- Temporary client IDs
Two people change the same thing
Both of you edit the same shape or sentence at the same moment. Whose change survives?
The options from locks to CRDTs, what each costs, and how to choose.
- Server-authoritative conflict handling
You can’t tell who else is here
Something moves under your mouse and you never saw who did it.
How to show cursors and who is active without flooding the network.
- Presence awareness
- Idle detection
- Follow mode
Cursors lag behind while you pan
Other people’s cursors swim and trail behind the board as you scroll.
Why it happens and the narrow fix.
- Synchronous UI flushing