MONITOR is the Redis command that streams every command processed by the server to the connecting client in real time. It is invaluable for diagnostics on a quiet staging instance and devastating on a busy production master. The Redis documentation warns about it; the warning is often ignored because the command sounds harmless. This article explains exactly why MONITOR is destructive on busy instances, the throughput collapse it causes, and the tools — SLOWLOG, LATENCY, INFO commandstats, and CLIENT NO-EVICT — that belong in your debugging toolkit instead.
How to verify
# What MONITOR does (briefly!) on staging
redis-cli MONITOR
# 1717326000.123456 [0 127.0.0.1:54321] "SET" "foo" "bar"
# 1717326000.123890 [0 127.0.0.1:54321] "GET" "foo"
# ... Ctrl-C IMMEDIATELY
# Safer alternatives
redis-cli SLOWLOG GET 50
redis-cli SLOWLOG RESET
redis-cli LATENCY HISTORY event-loop
redis-cli LATENCY LATEST
redis-cli INFO commandstats
What’s happening
MONITOR opens a persistent connection from a client and instructs the server to send a debug log line for every command it processes — not just commands from this client, but every command from every client connected to the server. The server formats each line, queues it on the monitor connection’s output buffer, and the client reads it.
The cost is multi-layered:
- Throughput collapse. Redis is single-threaded for command execution. Formatting and queuing the monitor line takes time per command — a busy master at 100,000 commands/sec slows dramatically while MONITOR is attached. We have seen 70-90% throughput drops on real production instances.
- Output buffer pressure. Each monitored command becomes a string on the monitor client’s output buffer. If the monitor client cannot read as fast as the server emits, the buffer fills toward
client-output-buffer-limit normal— and the connection gets disconnected. The server attempts to keep the buffer drained, which adds even more latency to command processing. - Memory. A long-running MONITOR on a busy server can hold gigabytes in the output buffer briefly. Memory pressure on top of throughput collapse is a recipe for tipping the daemon.
- Replica impact. A MONITOR connection on the master does not stream the replication traffic (replication is a separate channel), but the master’s throughput collapse propagates: replicas have no writes to apply, the application sees timeouts, and the system stalls.
The brief exception: MONITOR is fine on staging, on instances with under 100 commands/sec, or for the few seconds it takes to capture a sample on a quieter dev environment. Never leave it running unattended, and never attach it to a production master.
The fix (what to use instead)
The right tools are the per-command stats and slow-log primitives that Redis maintains continuously, at near-zero cost.
-
SLOWLOG— Redis keeps the N slowest commands in a ring buffer. The threshold is configurable. This is the primary tool for “which queries are slow?”redis-cli CONFIG SET slowlog-log-slower-than 10000 # microseconds (10 ms) redis-cli CONFIG SET slowlog-max-len 256 redis-cli SLOWLOG GET 20 # 1) 1) (integer) 14 # 2) (integer) 1717326000 # 3) (integer) 12300 # microseconds # 4) 1) "KEYS" # the command and args # 2) "*" # 5) "127.0.0.1:54321" # client # 6) "" redis-cli SLOWLOG RESETSet the slower-than threshold to your latency budget; alert on entries appearing.
-
LATENCY— Redis self-monitors specific latency events. Configure latency monitoring and read it back:redis-cli CONFIG SET latency-monitor-threshold 100 redis-cli LATENCY LATEST # 1) 1) "event-loop" # 2) (integer) 1717326100 # 3) (integer) 152 # 4) (integer) 152 redis-cli LATENCY HISTORY event-loop redis-cli LATENCY DOCTORLATENCY DOCTORprints human-readable diagnoses with suggestions. -
INFO commandstats— per-command counts and average latency:redis-cli INFO commandstats # cmdstat_set:calls=1234567,usec=8765432,usec_per_call=7.10 # cmdstat_get:calls=9876543,usec=1234567,usec_per_call=0.12Use this to find the command consuming the most cycles.
usec_per_call * callsgives total time spent per command. -
CLIENT LISTandCLIENT NO-EVICT— see who is connected and protect a debugging connection from being disconnected for buffer pressure:redis-cli CLIENT LIST # id=42 addr=10.0.0.5:54321 fd=12 name=cartapp age=12345 idle=0 ... redis-cli CLIENT NO-EVICT ON -
OBJECT FREQ/OBJECT IDLETIME— per-key access counters (LFU and LRU bookkeeping). Useful for finding hot keys withoutMONITOR:redis-cli OBJECT FREQ somekey redis-cli --hotkeys -
redis-cli --bigkeysandredis-cli --memkeys— sampling-based analysis that does not stress the server:redis-cli --bigkeys -i 0.01 -
For deep sampling, run MONITOR on a read replica if you really need to see commands. The replica receives replicated writes; you see them streaming and the production master is untouched. This is the closest safe approximation if you genuinely need command-stream visibility.
Common pitfalls
- A developer attaches MONITOR to look at “just one query” and forgets to detach. The session goes to sleep, the buffer fills, the server slows by 70%, and the on-call gets paged. Always Ctrl-C immediately, or use
timeout 5 redis-cli MONITOR. - ACL-protected MONITOR (Redis 6+):
+monitoris a separately granted capability; users without it cannot MONITOR. Lock it down so only operators can use it. SLOWLOGis in-memory only — it does not survive restarts. Ship the entries to Loki or an audit log if you care about retention.INFO commandstatsreturns cumulative totals since startup. To compare across windows, diff two snapshots a minute apart.LATENCY DOCTORis more useful thanLATENCY LATESTfor ad-hoc debugging — it correlates events and suggests fixes (e.g., fork latency from BGSAVE).
In the engagements we run, MONITOR is on the +@admin allow-list with the user expected to know what they are doing — and the standard runbook for “Redis is slow” starts with SLOWLOG and LATENCY, not MONITOR. We operate that under Managed Operations — and a common follow-up after MONITOR misuse is to revisit memory tuning since the output buffer was the first thing to break.