Introduction
Redis slowlog records commands whose execution time crossed the configured threshold. When the slowlog keeps growing, the real task is to find which commands are slow, why they are slow, and whether the threshold still matches the workload.
Symptoms
- SLOWLOG GET returns many repeating expensive commands
- Redis latency increases during spikes
- A few command patterns dominate the slowlog
Common Causes
- Expensive commands such as KEYS, large Lua scripts, or wide range scans
- One hot client repeatedly sending slow patterns
- Memory pressure or persistence activity increasing latency
Step-by-Step Fix
- 1.Inspect the slowlog and find the repeating command pattern
- 2.Start by checking whether the issue is one expensive command or many smaller spikes from the same client.
redis-cli SLOWLOG LEN
redis-cli SLOWLOG GET 20- 1.Check whether server pressure is amplifying command time
- 2.A command that is normally acceptable can still land in the slowlog during persistence, CPU pressure, or memory churn.
redis-cli INFO stats
redis-cli INFO memory
redis-cli LATENCY LATEST- 1.Trace the slow entry back to the caller
- 2.Match the command shape with the job, API endpoint, Lua script, or batch worker that is sending it.
- 3.Fix the command pattern before changing the threshold
- 4.Replace
KEYSwithSCAN, trim wide range queries, split oversized Lua scripts, or reduce payload size. - 5.Only tune slowlog settings after validating the workload
- 6.If the threshold is too aggressive for your environment, review it explicitly instead of clearing the log and moving on.
redis-cli CONFIG GET slowlog-log-slower-than
redis-cli CONFIG GET slowlog-max-lenPrevention
- Avoid production use of
KEYS, huge range scans, and oversized Lua jobs - Review slowlog growth alongside CPU, memory, and persistence events
- Keep batch jobs and background workers from concentrating expensive commands into spikes
- Treat
SLOWLOG RESETas cleanup, not as the actual fix