Cache Replication & Failover 00:00:01 A second copy lags the first A cache primary accepts an edit and sends it to a replica. Follow the update across the replication link before asking what a reader on the other machine can see. All three nodes hold user:1 and user:2. The client sets user:3 on the primary. The primary has it and replies ok. The replicas do not know it yet. The first replica receives it. A read that lands on replica 2 now does not find user:3. Moments later all three agree again. Distinguish accepting an edit, acknowledging it and having a particular replica apply it. A second copy helps availability only under a clear choice about these moments. 00:00:47 Promote a copy while the latest edit is travelling Stop the primary and choose a replacement. A reachable replica can be behind the last acknowledged state when replication was asynchronous. Each watcher pings the nodes. Pings are not answered. Writes fail. After the waiting time, one watcher marks it SDOWN. That alone starts nothing. A leader is authorised by a majority. Replica 1 has the same priority and more data, so it is promoted. Replica 2 follows the new primary and the client reconnects to it. It comes back as a replica and copies the new primary. Measure recovery time and the possible acknowledged-data loss separately. A quick promotion can improve one metric while exposing a less recent copy. 00:01:34 Decide when to send the acknowledgement Compare answering immediately with waiting for replicas according to a defined policy. The client observes a latency difference because the designs promise different amounts of completed replication work. Answer at once. If the primary dies, 5,000 times 0.02 equals about 100 writes are missing on the replica. Wait for one replica. Nothing is lost if that replica is the one promoted. Wait for all. The slowest replica sets the pace, and a lost replica stops writes. Successfully waiting for copies does not automatically make failover linearizable. Define durability, election and which surviving replica is eligible to serve next. 00:02:19 A network split has two persuasive stories Two machines lose communication. Each may still be reachable from a group of clients. If both believe they own the same writable key, recovery becomes a conflict rather than a simple promotion. Client 1 still reaches the old primary. The watchers and the replica cannot. The watchers have a majority and promote the replica. Client 2 writes there. Two primaries exist. With a minimum of one replica, the old primary refuses writes after the lag limit of 10 seconds. The old primary becomes a replica. Its writes from the split are thrown away. Use supported leadership and fencing mechanisms, and specify how clients discover the active owner. Health suspicion alone cannot revoke a remote process's ability to accept writes. 00:03:08 Read the saved edit from a replica A user saves a profile and immediately refreshes from another connection. The request can encounter a healthy replica whose applied position predates that edit. The name is written to the primary. The page shows the old name and the user saves again. For five seconds after a write, this user's reads go to the primary. Route a dependent read to a suitably fresh source, or wait for the required position. Replicated caches need an explicit read-your-writes policy when users depend on that experience.