# Notebook 9: Redis and Cassandra when something fails # run at: 2026-11-19 19:50 UTC # runner: Linux-7.0.0-1019-azure-x86_64-with-glibc2.43 | 4 vCPU Timings are from a client on the same machine and include the round trip. ## Redis ### 1. The process is killed (kill -9) while one client writes, then restarted AOF on, appendfsync everysec: acknowledged 40200, present after restart 40200, lost 0 AOF off, snapshots on the default schedule: acknowledged 42269, present after restart 0, lost 42269 Redis 7.4.12, one client, one SET per round trip: about 8040 writes a second Read it this way: a killed process does not lose what it already handed to the operating system. The AOF is written to the file before the reply, and only the fsync waits up to a second, so only a machine crash or power loss can lose that last second. With snapshots only, everything since the last snapshot is gone: the default schedule had not taken one yet. ### 2. Failover to a lagging replica The replica is frozen (docker pause) for one second to stand in for a slow network or a busy replica. The primary is killed during that second, then the replica is unfrozen and promoted. plain SET, replication is asynchronous: acknowledged 29981, on the promoted replica 27764, lost 2217. Median write 0.132 ms SET then WAIT 1 500, count only confirmed writes: acknowledged 9894, 1 of them reported unconfirmed by WAIT; confirmed and lost: 0. Median write 0.299 ms Read it this way: the primary acknowledges a write before any replica has it. Writes acknowledged while the replica was behind are gone after the promotion. WAIT does not stop that, but it tells the client which writes no replica confirmed, so the application can retry them or report them. It does not make Redis a consensus system. ## Cassandra: three nodes, replication factor 3 cluster of 3 up in 139 s -- Address Load Tokens Owns (effective) Host ID UN 172.18.0.3 80.02 KiB 16 59.3% 1840ea45-98cf-4cec-aeb7-c5ad7552a155 UN 172.18.0.2 119.83 KiB 16 64.7% b4f5ca88-5c68-4577-9116-f2c49c185178 UN 172.18.0.4 30.88 KiB 16 76.0% d73d5592-9df2-429a-8354-9b7f1c4f2bd8 # Cassandra: 5.0.9 ### 1. All three nodes up: 500 writes and 500 reads at each consistency level 3 of 3 up: ONE writes ok 500 of 500 reads found 500 median write 2.05 ms, read 1.86 ms 3 of 3 up: QUORUM writes ok 500 of 500 reads found 500 median write 1.51 ms, read 2.32 ms 3 of 3 up: ALL writes ok 500 of 500 reads found 500 median write 1.27 ms, read 1.92 ms ### 2. One node stopped 2 of 3 up: ONE writes ok 500 of 500 reads found 500 median write 0.74 ms, read 0.77 ms 2 of 3 up: QUORUM writes ok 500 of 500 reads found 500 median write 0.92 ms, read 1.02 ms 2 of 3 up: ALL writes ok 0 of 500 (Unavailable) reads found 0 median write nan ms, read nan ms ### 3. Two nodes stopped 1 of 3 up: ONE writes ok 500 of 500 reads found 500 median write 0.41 ms, read 0.59 ms 1 of 3 up: QUORUM writes ok 0 of 500 (NoHostAvailable) reads found 0 median write nan ms, read nan ms 1 of 3 up: ALL writes ok 0 of 500 (NoHostAvailable) reads found 0 median write nan ms, read nan ms ### 4. Both nodes back. Do they get the writes they missed? pending hints on the other nodes: none after 15 s with only node 3 running, reads at ONE of the 1500 writes it missed while down: 1500 found (1,000 written at ONE and QUORUM with node 3 down, 500 at ONE with nodes 2 and 3 down) Read it this way: with three copies, QUORUM needs two. One node down, QUORUM still works and ALL fails at once with Unavailable. Two down, only ONE works, and those writes live on one machine until the others come back and hints (kept up to max_hint_window, 3 hours by default) or repair copy them.