Home›Learn›Redis 5: when it breaks
Redis · Chapter 5

When Redis breaks

The app is slow and Redis is the suspect. Now what?

The failures to plan for, and the playbook from symptom to fix.

What breaks first

The failures I would plan for

What happensWhat you seeWhat I do
A big keyOne DEL or HGETALL on a hash with millions of fields blocks every client for hundreds of millisecondsFind it with redis-cli --bigkeys and MEMORY USAGE. Split it into smaller keys. Delete big keys with UNLINK, which frees memory in the background.
A hot keyOne shard at 100% CPU while the others idleA key lives on one shard and one thread. Spread it over several keys, or count in the application and write once a second.
KEYS * or a long Lua script in productionEverything stalls while it runs; SLOWLOG fills upSCAN instead of KEYS. Keep scripts short.
Memory fullWith noeviction, writes fail with an OOM error. With an eviction policy, keys quietly disappearSet maxmemory and a policy that matches the job. Alert well before the limit.
A fork on a big, busy instanceLatency spikes during snapshots and AOF rewrites; memory jumps; sometimes the out-of-memory killerLeave memory headroom, turn off transparent huge pages, and take snapshots on a replica.
A replica that keeps falling behindFull resync loops: fork, copy everything, fall behind againA bigger repl-backlog-size and client-output-buffer-limit for replicas.
Failover with asynchronous replicationThe newest writes, already acknowledged, are missing after a replica is promotedKeep only data you can rebuild in Redis, or accept and document the window.
Chapter 5 · When it breaks

Start from what you see

← Chapter 4: Running it as a DBREYou finished the Redis trackBack to chapter 1Or pick another database in the Learn menu.
Part 1 of 4 · Learn · 56 pagesAll pages

How do databases actually work? From one row on disk to transactions: the words you need, PostgreSQL, MySQL and MongoDB from the files up, then Redis, Cassandra and vector search, side by side, and the query and concurrency traps.

Start 1: the basicsStart 2: ten conceptsStart 3: how a query travelsStart 4: napkin mathThe courseShort videosPostgreSQL 1: why PostgreSQLPostgreSQL 2: how it stores your dataPostgreSQL 3: what happens on every writePostgreSQL 4: high availability with PatroniPostgreSQL 5: running it as a DBREPostgreSQL 6: when it breaksPostgreSQL on Kubernetes: CloudNativePGMySQL 1: why MySQLMySQL 2: how it stores your dataMySQL 3: what happens on every writeMySQL 4: high availability with InnoDB ClusterMySQL 5: running it as a DBREMySQL 6: when it breaksMySQL failover with OrchestratorMySQL on Kubernetes: the Percona operatorsMongoDB 1: why MongoDBMongoDB 2: how it stores your dataMongoDB 3: what happens on every writeMongoDB 4: high availability with replica setsMongoDB 5: running it as a DBREMongoDB 6: when it breaksMongoDB on Kubernetes: the Percona operatorB-tree and LSM treeRedis 1: why RedisRedis 2: how it stores your dataRedis 3: high availabilityRedis 4: running it as a DBRERedis 5: when it breaksCassandra 1: why CassandraCassandra 2: how it stores your dataCassandra 3: high availabilityCassandra 4: running it as a DBRECassandra 5: when it breaksVector databases 1: why vector searchVector databases 2: how it stores your dataVector databases 3: high availabilityVector databases 4: running it as a DBREVector databases 5: when it breaksDatabase familiesEngines side by sideQueries that look fine and are notLost updates and write skewMany servers 1: keep a copy runningMany servers 2: who is the leaderMany servers 3: CAP as settingsMany servers 4: unique IDsMany servers 5: split the dataMany servers 6: across servicesMany servers 7: a thousand databasesStaff path, zero to architect