Blogs

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.

In one minute
  1. 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.
  2. 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.

Sequence
Alice Server Bob load v1 (title “Draft”) load v1 (title “Draft”) save: title = “Plan” v2 · title “Plan” save whole copy: color = red v3 · title “Draft”, red Alice’s title is gone, and nobody was told v1v1Planred
Bob saved a copy that was already out of date. The server had no way to know, so it accepted it and overwrote Alice’s work.

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.

Compare · animated

1Save + spinner

Alice’s screenBob’s screenAliceSaving…still the old positionAlice drags the boxSaving… Alice has to waitBob still sees the old version

Everyone waits on every save, and nobody sees the others until they reload.

2Version check

Alice’s screenBob’s screensaved ✓ (version 2)BobSomeone changed this.Reload and loseyour edits?Alice recolors the box and savesBob moves it, based on version 1Bob’s save is rejected

No work is silently lost, but whoever saves second has to redo it.

3Lock the file

Alice’s screenBob’s screenAliceLocked: Alice is editingview onlyAlice opens the file and gets the lockBob can only watchHe waits until Alice closes it

Safe and simple, but only one person can work at a time.

4Realtime sync

Alice’s screenBob’s screenAliceAliceBobBobAlice drags the box; Bob sees it moveBob moves the circle; Alice sees it tooNo saving, no waiting, no lock

Both work at once and see each other’s changes as they happen.

The same moment, four ways. Each step down removes a kind of waiting, and costs more to build.

The simpler approaches are not wrong. Each one is the right answer for some products:

ApproachEnough whenBreaks down whenYou see it in
Save + spinnerEdits are occasional and fit in a formActions are continuous, like dragging or typing, or others need to see themSettings pages, admin panels
Version checkTwo people rarely edit the same record, and redoing is cheapMany people edit the same thing at once, so rejections pile upWiki “edit conflict” pages, APIs with ETag / If-Match
LockOne person edits at a time and taking turns feels naturalWorking together is the point, or someone forgets to unlockSharePoint check-out, WordPress post locks, Git LFS file locks
Realtime syncSeveral people work in the same place at the same time, every action must feel instant, and seeing each other mattersIt is overkill for forms and turn-taking, and it costs real engineering effort (the rest of this series)Google Docs, Figma, Miro, multiplayer games
Key ideaRealtime sync is the answer to waiting, not to lost updates. A version check already prevents lost updates. Realtime removes the spinner, the rejected save and the lock, so people can work in the same place at the same time. Reach for it only when that is what the product is for.

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 caseWhat has to stay in syncHow often people collide
Shared documentsA long stream of charactersOften: people type in the same paragraph
SpreadsheetsCells and formulasSometimes: the same cell or a dependent one
Whiteboards & design toolsA tree of objects with propertiesRarely: people spread out across the board
Task trackersRecords with fields (status, owner)Sometimes: two people move the same card
Chat & commentsAn append-only list of messagesAlmost never: messages are added, not changed
Multiplayer gamesGame state, many times per secondConstantly, 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.

1

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
2

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
3

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
4

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
5

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