Apache ZooKeeper 00:00:01 Three dispatch offices change one timetable Two train dispatchers need one agreed timetable. Their coordination record currently says one. A client attached to a follower asks ZooKeeper to change it to two. Trace where that request must go before it can be acknowledged. The client is connected to follower 1 and asks for x = 2. Followers pass every change to the leader, so that one place decides the order. The leader assigns the proposed change a transaction identifier and records it in its log. Follower 1 acknowledges. With the leader that is 2 of 3: committed, even though follower 2 has not answered. Once committed, servers apply changes in the agreed order. The connected server returns the result to the client. In the three-voter ensemble, an acknowledging follower and the leader make a majority. The other follower may apply the committed change later. Agreement about write order and simultaneous visibility at every client are different promises. 00:01:09 Two readers see different timetable versions Immediately after the write, ask two clients connected to different servers what the timetable says. A low-latency local read is attractive precisely because it does not have to consult a fresh quorum for every question. Client A reads x = 2 from follower 1's memory. No other server is asked. Client B reads from follower 2, which has not applied the change yet, and sees x = 1. In this illustrated sequence, the second client synchronizes with the leader before its next read, allowing the lagging follower to catch up. That client now reads two. The earlier value was a real earlier state seen through a different connection. Do not turn this example into a claim that every ordinary read is linearizable. Choose a protocol that matches the application's required ordering and keep dependent operations in a consistent session. 00:02:09 A missing dispatcher and an expired session A dispatcher registers its temporary presence using an ephemeral node attached to a session. Unplugging one network cable does not instantly prove that the dispatcher has stopped. The service needs time to distinguish disconnection from expiration. The service creates an ephemeral registration under the example services path. After 10 s without traffic the client sends a ping. Later the process actually stops. Until expiration is established, its registration can still appear. 30 s pass. The leader expires the session, the node is deleted, and watchers are told. With the negotiated thirty-second timeout in this case, expiration removes the ephemeral registration. A client can reconnect within its session window, so other dispatchers should react to observed coordination state rather than to a guess about the remote process. 00:03:06 A notification is an invitation to reread Now the timetable is a configuration record. One dispatcher reads version one and asks for a standard one-shot watch. While that dispatcher is busy, two edits arrive in quick succession. Client A reads config 1 and leaves a watch on the same call. Config 2 is committed. The watch fires and is removed. Version three arrives after the first watch has fired and before the client installs another. There is no remaining one-shot watch for that second change. A reads config 3 and sets a new watch. It never saw 2, and ends up right. The client can end up correctly using version three without ever observing version two. Re-establish the watch while reading current state. A standard watch is a change notification, not a durable event-by-event ledger. 00:03:58 A suspended holder comes back too late A dispatch worker holds token thirty-three, then pauses long enough to lose its session. A replacement acquires thirty-four and writes to the protected destination. Predict what the original worker can still attempt when it resumes. Worker A holds lock node 33 and starts a job. A freezes for longer than its timeout. Its node vanishes and B takes over with 34. After the replacement writes with thirty-four, the previous holder resumes and presents thirty-three to the same storage. The storage remembers 34 and refuses 33. The data is safe. The destination must compare and enforce a monotonically ordered fencing token. An expired registration alone cannot stop an old process from sending a delayed write. That is the difference between naming a current dispatcher and protecting the timetable it edits.