Failure Scenarios
The ways Redis breaks in production, and how each looks
Most Redis incidents fall into a short list. Several of them were reproduced while building this module, and are marked as such.
| # | Failure | Symptom | Where to look | Fix |
|---|---|---|---|---|
| 1 | Slow command | Latency spikes for every client | SLOWLOG GET, LATENCY LATEST | Replace O(N) commands (KEYS, HGETALL on big keys, unbounded LRANGE); SCAN; split big keys |
| 2 | Memory limit reached | OOM command not allowed (noeviction) or rising evicted_keys | INFO memory, INFO stats | TTLs, find big keys (--memkeys), raise maxmemory, separate cache and data |
| 3 | Container OOM-killed during save | Redis restarts during BGSAVE/AOF rewrite | Exit code 137, rdb_last_cow_size | Headroom above maxmemory; vm.overcommit_memory=1; disable THP |
| 4 | Persistence failing | MISCONF ... unable to persist to disk; writes refused | INFO persistence, logs | Disk space, permissions; alert on rdb_last_bgsave_status |
| 5 | Lost writes on crash (reproduced) | Acknowledged writes missing after a kill | Compare before/after counts | appendfsync always if a second matters; or a real database |
| 6 | Old primary can't rejoin (reproduced) | master_link_status:down after failover | INFO replication on the old primary | masterauth/masteruser on every node |
| 7 | Lost writes on failover | Recent data missing after Sentinel promotes a replica | Replica offsets at failover time | Async replication: WAIT, min-replicas-to-write; accept or redesign |
| 8 | Full resync storm | Replicas repeatedly full-syncing; primary forking constantly | Primary log: "Full resync requested" | Bigger repl-backlog-size; raise replication buffer limits |
| 9 | Restore silently not applied (reproduced) | Old or empty data after restoring a backup | Startup log: which file loaded | Load RDB with AOF off, then enable AOF; stop replicas/Sentinel first |
| 10 | Cluster down (reproduced) | CLUSTERDOWN The cluster is down on every node | CLUSTER INFO | A primary and its replica both failed; spread across zones; cluster-require-full-coverage |
| 11 | Connection exhaustion | max number of clients reached; rejected_connections rising | INFO clients, CLIENT LIST | Pool sizes × app instances < maxclients; fix connection leaks |
| 12 | Slow consumer disconnected | Pub/Sub subscribers silently miss messages | CLIENT LIST omem; logs: "scheduled to be closed" | Faster consumers; streams instead of Pub/Sub |
| 13 | Hot key | One node or the main thread at 100% while others idle | --hotkeys, INFO commandstats | Client-side caching, key replication, replica reads |
| 14 | Cache stampede | Database load spikes when a hot key expires | DB metrics aligned with expiry | Rebuild locks, early refresh, TTL jitter |
Reading the signals
"Redis is slow." Check, in order: SLOWLOG GET (a slow command?),
LATENCY LATEST (fork, AOF, or expiry spikes?), INFO stats
instantaneous_ops_per_sec (simply overloaded?), redis-cli --latency
from the client host (network?), and INFO memory
mem_fragmentation_ratio below 1 (swapping?).
"Data disappeared." Was it evicted (evicted_keys rising)? Did it
expire (did it have a TTL; did a plain SET clear one, or set one by
mistake)? Was there a failover (INFO replication, Sentinel logs)? A
restart without persistence? A FLUSHALL (ACL LOG, INFO commandstats
cmdstat_flushall)?
"Writes are failing." OOM → memory. MISCONF → persistence.
READONLY → you're talking to a replica, often a client that didn't
follow a failover. NOPERM → ACLs. CLUSTERDOWN / MOVED loops →
cluster topology.
Many of the worst Redis incidents come from treating it as a database without the protections a database has: data that exists nowhere else, on an instance with eviction enabled, persistence off, and async replication. For each key pattern, write down the answer to "what happens if this disappears right now?" and configure accordingly.
Game day
Run these against the lab stack one at a time and note what alerted and what the dashboard showed:
# 1. memory pressure: fill a throwaway instance with a small maxmemory (see Eviction)
# 2. slow command (DEBUG SLEEP is blocked here by enable-debug-command no, so use a script)
docker exec redis redis-cli --user default --pass redis123 EVAL "local i=0 while i < 1e8 do i=i+1 end" 0
# 3. primary failure with Sentinel
docker stop redis
# 4. replica failure
docker stop redis-replica-1
# 5. cluster shard loss (primary + its replica)
docker stop redis-node-2 redis-node-6 # pick a primary and its replica from CLUSTER NODES
# 6. connection exhaustion
docker exec redis redis-cli --user default --pass redis123 CONFIG SET maxclients 5
# then open more connections than that