Google Docs 00:00:01 Follow one keystroke Two writers place their cursors at the same character and both type before hearing from the other. Each is entitled to an immediate local response. The shared document still needs one explainable order for the edits. The screen shows it immediately. Typing must never wait for a network. Every editor of this document reaches the same owner. One place must choose the order. The owner looks for this sequence number and checks that Alice may still edit. Retries must not type twice and a revoked editor must stop. Insert the row only if revision 42 does not exist, on several copies. An edit we confirm must survive a crash. Alice learns that the edit is revision 42 and drops it from the waiting list. Now the client may send the next one. After 1,000 edits a background job writes the whole document. Opening it must not replay years of typing. In this illustrative editor, the client applies an optimistic local edit and tracks a pending operation. The authoritative revision later lets it tell which part of its own work is actually confirmed. 00:01:19 At the same position Both type at position 5 of revision 10. The order of arrival decides, so both letters survive. At position 5, on revision 10. It shows at once. At the same position and on the same revision, before Alice's edit gets there. Alice arrived first and became revision 11. Bob's edit is still based on 10. A sits at 5, so Bob's B moves to 6. It becomes revision 12. The A is confirmed at 5, and B arrives for position 6. Bob receives A before B is confirmed. That client uses the same rule, so the B moves from 5 to 6. Resolve the tie by the document's specified operation-ordering rule. Network arrival on two different laptops cannot by itself guarantee that both replicas will choose the same final text. 00:02:19 Move a position through an earlier edit Start with Hello. Alice inserts X at 2 while Bob inserts Y at 4. Count the letters yourself. Both copies say Hello at revision 5. Alice's screen says HeXllo. Bob's says HellYo: position 4 is just before the o. The owner applies X. Revision 6 is HeXllo. X was inserted at 2, before 4. One letter was added, so 4 becomes 5. Y still lands just before the o, where Bob wanted it. Revision 7 is HeXllYo. An insertion can change the position at which a later operation should apply. Transform against the correct revision and preserve intent according to the defined editing rules. 00:03:15 A train loses its connection No network for an hour. Edits wait on the device, then are replayed on top of what others did. A heartbeat fails. Alice keeps typing. A document that stops is worse than one that syncs late. Each is written to IndexedDB with its base revision and sequence. The screen says saved on this device. The browser reports a network and the client opens its connection. It must ask before it sends. Missed edits are shifted over mine for the screen; mine are shifted over the missed ones for the server. The rewritten edits go up with their old sequence numbers, so a second try changes nothing. Confirmed edits leave IndexedDB. If a whole section changed, the client offers a review. Local persistence protects the user's unacknowledged operations. On reconnect, compare revisions and reconcile with remote changes before declaring the offline edits safely incorporated. 00:04:22 Only one document owner may commit A server dies with your last word, and then comes back confused. Server 12 holds the lease and owns the document at revision 42. Its lease runs out. Editors see reconnecting and keep typing into their own queue. Server 31 takes the lease, loads the snapshot and replays the log up to 42. Clients resend what was not confirmed. Sequence numbers remove anything that was already stored. It tries to write revision 43, which exists. The insert fails, so it steps down. A replacement owner must establish authority before it can publish a revision. Stale owners need a durable check on the revision or leadership epoch at the actual write boundary. 00:05:14 Readers do not each need an editor A link goes to the whole company at 9:00. 10,000 people reach one owner. It cannot push every edit to each of them. The first 100 editors stay on the owner. Others become readers for now and are told why. The edge serves the latest snapshot, and fan-out servers pass on one batch of edits each second. Readers see a count, not 10,000 carets. Distributing a committed edit to thousands of followers is separate from serializing conflicting writes. Aggregate transient presence so that ten thousand cursors do not become ten thousand permanent document operations. A visible keystroke, a committed revision and an ephemeral cursor are three different facts. Give each the durability and ordering its real role requires.