Monitoring and Debugging
1. Getting Server Info
| Section | Content |
|---|---|
INFO server | Version, uptime, OS, PID |
INFO clients | connected_clients, blocked, tracking |
INFO memory | Memory usage and fragmentation |
INFO stats | Commands processed, hit/miss |
INFO replication | Role, offset, lag |
INFO commandstats | Per-command count + microseconds |
INFO latencystats | Per-command latency histograms 7.0+ |
2. Monitoring Real-Time Commands
| Command | Description |
|---|---|
MONITOR | Stream every command in real time PERF COST |
3. Using SLOWLOG
| Command | Description |
|---|---|
SLOWLOG GET [n] | N most-recent slow entries |
SLOWLOG LEN | Number of entries |
SLOWLOG RESET | Clear log |
slowlog-log-slower-than 10000 | Microsecond threshold |
slowlog-max-len 128 | Buffer length |
4. Configuring Latency Monitor
| Command | Description |
|---|---|
CONFIG SET latency-monitor-threshold 100 | ms threshold |
LATENCY LATEST | Most recent event per type |
LATENCY HISTORY event | Time series |
LATENCY DOCTOR | Human-readable diagnosis |
LATENCY GRAPH event | ASCII chart |
LATENCY RESET | Clear history |
5. Using DEBUG Command
| Command | Description |
|---|---|
DEBUG SLEEP seconds | Block server (testing only) |
DEBUG OBJECT key | Internal encoding details |
DEBUG JMAP | jemalloc heap dump |
DEBUG SET-ACTIVE-EXPIRE 0 | Disable active expire (debug) |
6. Profiling Performance
| Tool | Use |
|---|---|
redis-cli --latency | Continuous PING latency |
redis-cli --latency-history | Periodic samples |
redis-cli --latency-dist | Spectrum chart |
redis-cli --intrinsic-latency | OS scheduling jitter |
7. Tracking Client Statistics
| Source | Field |
|---|---|
INFO clients | connected_clients, blocked_clients, tracking_clients |
CLIENT LIST | Per-conn idle, sub, multi, cmd |
8. Monitoring Replication Stats
| Field | Meaning |
|---|---|
| role | master / slave |
| connected_slaves | Replica count |
| master_repl_offset | Bytes written |
| slave_repl_offset | Replica position |
9. Debugging Slow Queries
| Step | Action |
|---|---|
| 1 | SLOWLOG GET 50 |
| 2 | Check INFO commandstats for outlier commands |
| 3 | Use --bigkeys for large-value commands |
| 4 | Switch O(N) commands (KEYS) to SCAN family |
10. Using Redis CLI Tools
| Flag | Use |
|---|---|
--stat | Periodic stats summary |
--scan --pattern | Iterate matching keys |
--hotkeys | Identify most-accessed keys (LFU policy) |
--cluster check/info/reshard | Cluster admin |