Learn Labs
Operations

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.

#FailureSymptomWhere to lookFix
1Slow commandLatency spikes for every clientSLOWLOG GET, LATENCY LATESTReplace O(N) commands (KEYS, HGETALL on big keys, unbounded LRANGE); SCAN; split big keys
2Memory limit reachedOOM command not allowed (noeviction) or rising evicted_keysINFO memory, INFO statsTTLs, find big keys (--memkeys), raise maxmemory, separate cache and data
3Container OOM-killed during saveRedis restarts during BGSAVE/AOF rewriteExit code 137, rdb_last_cow_sizeHeadroom above maxmemory; vm.overcommit_memory=1; disable THP
4Persistence failingMISCONF ... unable to persist to disk; writes refusedINFO persistence, logsDisk space, permissions; alert on rdb_last_bgsave_status
5Lost writes on crash (reproduced)Acknowledged writes missing after a killCompare before/after countsappendfsync always if a second matters; or a real database
6Old primary can't rejoin (reproduced)master_link_status:down after failoverINFO replication on the old primarymasterauth/masteruser on every node
7Lost writes on failoverRecent data missing after Sentinel promotes a replicaReplica offsets at failover timeAsync replication: WAIT, min-replicas-to-write; accept or redesign
8Full resync stormReplicas repeatedly full-syncing; primary forking constantlyPrimary log: "Full resync requested"Bigger repl-backlog-size; raise replication buffer limits
9Restore silently not applied (reproduced)Old or empty data after restoring a backupStartup log: which file loadedLoad RDB with AOF off, then enable AOF; stop replicas/Sentinel first
10Cluster down (reproduced)CLUSTERDOWN The cluster is down on every nodeCLUSTER INFOA primary and its replica both failed; spread across zones; cluster-require-full-coverage
11Connection exhaustionmax number of clients reached; rejected_connections risingINFO clients, CLIENT LISTPool sizes × app instances < maxclients; fix connection leaks
12Slow consumer disconnectedPub/Sub subscribers silently miss messagesCLIENT LIST omem; logs: "scheduled to be closed"Faster consumers; streams instead of Pub/Sub
13Hot keyOne node or the main thread at 100% while others idle--hotkeys, INFO commandstatsClient-side caching, key replication, replica reads
14Cache stampedeDatabase load spikes when a hot key expiresDB metrics aligned with expiryRebuild 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.

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

On this page