Skip to content

Commit 8b08bbb

Browse files
committed
Do not encourage implementing your own synchronization protocol
1 parent 8bf518a commit 8b08bbb

1 file changed

Lines changed: 28 additions & 6 deletions

File tree

src-docs/faq/storage.md

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,36 @@ no feedback on delivery status.
3333
There is only a "best effort" approach.
3434
Messengers will typically queue messages and attempt delivery repeatedly.
3535

36-
If you want guarantees for peers receiving updates,
37-
you need to implement your own reliability protocol in your app.
38-
Common techniques include assigning sequence numbers or linked IDs to all updates you send,
39-
and implementing a way for receivers to request re-sending if updates are missing.
36+
Applications should assume that updates
37+
may be reordered and some updates may be lost.
4038

39+
For small documents, like a shopping list,
40+
it is appropriate to send the whole
41+
document state as an update each time
42+
and merge incoming documents on reception.
43+
This way changes can only be lost
44+
if original sender fails to deliver
45+
update to anyone else in the chat
46+
and stops using the app.
47+
48+
For documents consisting of independent parts,
49+
like spreadsheet consisting of cells,
50+
similar approach can be applied
51+
independently to each part.
52+
53+
For some applications
54+
like games updating the scoreboard
55+
it is fine to send new high scores
56+
as individual update,
57+
because if some update is lost
58+
it is not critical.
59+
60+
If you have complex documents and have
61+
to optimize for the size of updates
62+
by encoding the difference between the document states,
63+
you have to implement a synchronization protocol yourself.
4164
As with all "network synchronization" topics there are some theoretical limits.
4265
In particular it is useful to study and think about
4366
the [Two-Generals problem](https://en.wikipedia.org/wiki/Two_Generals'_Problem)
4467
and learn about existing "reliability layer" protocols
45-
before attempting to implement one yourself.
46-
68+
before attempting to implement one yourself.

0 commit comments

Comments
 (0)