Monitoring and Debugging

1. Getting Server Info

SectionContent
INFO serverVersion, uptime, OS, PID
INFO clientsconnected_clients, blocked, tracking
INFO memoryMemory usage and fragmentation
INFO statsCommands processed, hit/miss
INFO replicationRole, offset, lag
INFO commandstatsPer-command count + microseconds
INFO latencystatsPer-command latency histograms 7.0+

2. Monitoring Real-Time Commands

CommandDescription
MONITORStream every command in real time PERF COST

3. Using SLOWLOG

CommandDescription
SLOWLOG GET [n]N most-recent slow entries
SLOWLOG LENNumber of entries
SLOWLOG RESETClear log
slowlog-log-slower-than 10000Microsecond threshold
slowlog-max-len 128Buffer length

4. Configuring Latency Monitor

CommandDescription
CONFIG SET latency-monitor-threshold 100ms threshold
LATENCY LATESTMost recent event per type
LATENCY HISTORY eventTime series
LATENCY DOCTORHuman-readable diagnosis
LATENCY GRAPH eventASCII chart
LATENCY RESETClear history

5. Using DEBUG Command

CommandDescription
DEBUG SLEEP secondsBlock server (testing only)
DEBUG OBJECT keyInternal encoding details
DEBUG JMAPjemalloc heap dump
DEBUG SET-ACTIVE-EXPIRE 0Disable active expire (debug)

6. Profiling Performance

ToolUse
redis-cli --latencyContinuous PING latency
redis-cli --latency-historyPeriodic samples
redis-cli --latency-distSpectrum chart
redis-cli --intrinsic-latencyOS scheduling jitter

7. Tracking Client Statistics

SourceField
INFO clientsconnected_clients, blocked_clients, tracking_clients
CLIENT LISTPer-conn idle, sub, multi, cmd

8. Monitoring Replication Stats

FieldMeaning
rolemaster / slave
connected_slavesReplica count
master_repl_offsetBytes written
slave_repl_offsetReplica position

9. Debugging Slow Queries

StepAction
1SLOWLOG GET 50
2Check INFO commandstats for outlier commands
3Use --bigkeys for large-value commands
4Switch O(N) commands (KEYS) to SCAN family

10. Using Redis CLI Tools

FlagUse
--statPeriodic stats summary
--scan --patternIterate matching keys
--hotkeysIdentify most-accessed keys (LFU policy)
--cluster check/info/reshardCluster admin