Lesson 7 of 9 · 21m
Operating Redis: Metrics, Logs, Slowlog, and Safe Maintenance
The operational signals that predict failure, how to inspect latency safely, and the maintenance habits that prevent self-inflicted outages.
Redis is usually fast until the day it is not. Because it is single-threaded for command execution, one expensive operation, one slow disk flush, or one overloaded event loop affects everything behind it. Operations is therefore about detecting small stalls before they become queueing, and refusing maintenance practices that turn a healthy node into a latency experiment.
Start with INFO, but read it like an operator
redis-cli INFOThe useful sections are not decorative:
memory— usage, RSS, fragmentation, eviction pressure.stats— instantaneous ops, rejected connections, expired/evicted keys.persistence— last save/rewrite status, fork duration, failures.replication— role, lag, link state, backlog health.clients— connected and blocked clients, output buffer pressure.cpu— process CPU versus system pressure.
Graph rates, not just current values. expired_keys climbing can be normal; evicted_keys climbing means capacity is being sacrificed.
SLOWLOG is command evidence, not a profiler
redis-cli SLOWLOG GET 20
redis-cli SLOWLOG LENSlowlog records commands that exceeded slowlog-log-slower-than microseconds. It is in-memory, bounded, and per-node. It does not include time waiting in socket buffers or blocked behind another slow command; it measures execution duration.
Use it to answer 'what expensive command entered the server?' Use latency metrics and tracing to answer 'why did users wait?'
LATENCY HISTORY finds event classes
redis-cli LATENCY HISTORY command
redis-cli LATENCY HISTORY fork
redis-cli LATENCY LATESTFork latency is a classic Redis tax. Large memory plus copy-on-write pressure makes snapshotting visible. Transparent huge pages historically worsen memory and latency behavior for Redis; many operators disable THP for Redis hosts after testing.
Disk fsync stalls in AOF everysec can also dominate tail latency. Redis memory speed does not exempt you from disk reality.
Maintenance rules that keep you employed
- Upgrade one replica first; verify replication, persistence, and client behavior before touching the primary path.
- Never run
KEYS *, giantSMEMBERS, or unbounded Lua on a production primary to 'check something.' - Test failovers during business hours before they happen at 3 a.m.
- Keep connection counts bounded. A thousand application pods opening unlimited connections can exhaust memory and file descriptors.
- Drain or isolate nodes before heavy resharding, backup copies, or host maintenance.
Alert on causes, not only symptoms
used_memory near maxmemory is late. Alert earlier on fragmentation drift, eviction rate, replication link downtime, lag growth, AOF rewrite failures, fork duration, rejected connections, and blocked clients.
A good Redis dashboard should let you answer in thirty seconds: are we full, are we slow, are we replicated, are we failing over, and which command family changed?
Field notes
MONITORis diagnostic dynamite: it streams every command and can itself hurt a busy server.CONFIG GET/SETis useful but mutable runtime state is not configuration management. Persist deliberate changes in config management.- Clock jumps affect TTL logic and time-based scripts. Keep hosts disciplined with reliable NTP.
- One Redis process uses one core for command execution; adding cores to the host does not multiply command throughput linearly.
- TCP keepalive, TLS termination, proxies, and service meshes all add failure modes. Simplify the data path before optimizing it.
Was this lesson helpful?