The sync goal
When a client connects, it must reach the same state as everyone else while sending the least data. A document sync protocol exchanges a compact summary of what each side already has, then transfers only the missing pieces.
State vectors
Many systems use a state vector, a small map from each replica id to the highest update counter it has seen. Two clients swap vectors, compute the difference, and each sends exactly the updates the other lacks.
Two step handshake
- Step one sends my state vector so you can compute what I am missing.
- Step two sends the missing updates plus my own vector so the exchange is symmetric.
This delta based approach scales far better than shipping the whole document, which matters when a user reopens a large file after a short absence.
Key idea
A sync protocol swaps state vectors to compute differences and ships only the missing updates rather than the full document.