Key Concepts
Slow Log
An in-memory log of commands that exceeded the configured duration threshold.
Threshold
Commands slower than
slowlog-log-slower-than microseconds are logged.Execution Time
Time spent executing the command, not including network latency or queue time.
Log Size
Maximum entries stored is controlled by
slowlog-max-len configuration.Required Permissions
| Action | Permission |
|---|---|
| View slow log | iam:project:infrastructure:redis:read |
Duration Severity Levels
| Level | Duration | Meaning |
|---|---|---|
| Normal | < 10ms | Typical command execution |
| Warning | 10ms - 99ms | Potentially slow, worth investigating |
| Critical | >= 100ms | Very slow, likely impacting performance |
How to View Slow Log
How to Search Commands
How to Filter by Client
How to Filter by Duration
Select Duration Threshold
Choose from preset duration filters:
- All: Show all slow log entries
- > 1ms: Commands slower than 1 millisecond
- > 5ms: Commands slower than 5 milliseconds
- > 10ms: Commands slower than 10 milliseconds
- > 50ms: Commands slower than 50 milliseconds
- > 100ms: Commands slower than 100 milliseconds
Understanding Slow Log Entries
Each entry contains:| Field | Description |
|---|---|
| ID | Sequential entry number (decrements for older entries) |
| Timestamp | When the command was executed |
| Command | The full command with arguments |
| Client | IP address and port of the client |
| Client Name | Optional name set by CLIENT SETNAME |
| Duration | Execution time in microseconds/milliseconds |
Common Slow Commands
| Command | Why It’s Slow | Alternative |
|---|---|---|
KEYS * | Scans entire keyspace | Use SCAN with patterns |
SMEMBERS (large set) | Returns all members | Use SSCAN for pagination |
HGETALL (large hash) | Returns all fields | Use HSCAN or specific HGET |
SORT | CPU-intensive operation | Pre-sort data or use sorted sets |
LRANGE 0 -1 | Returns entire list | Paginate with offset/count |
DEBUG SLEEP | Intentional delay | Remove from production |
How to Configure Slow Log
The slow log is configured through Redis configuration parameters.Threshold Setting
| Value | Meaning |
|---|---|
10000 | Log commands slower than 10ms (default) |
1000 | Log commands slower than 1ms |
0 | Log all commands (debugging only) |
-1 | Disable slow log |
Maximum Entries
| Value | Meaning |
|---|---|
128 | Keep last 128 entries (default) |
1000 | Keep more history for analysis |
0 | Unlimited (uses memory) |
Configure these settings in the Redis Configuration page. Changes take effect immediately.
How to Clear Slow Log
The slow log can be cleared using Redis CLI:Troubleshooting
Slow log is empty
Slow log is empty
- The threshold may be set too high (lower
slowlog-log-slower-than) - Slow log may have been recently reset
- Commands may genuinely be fast
- Check if slow log is disabled (
slowlog-log-slower-than -1)
Too many entries
Too many entries
- Increase threshold to capture only slower commands
- Use duration filter to focus on critical entries
- Check for problematic command patterns
- Consider application optimization
Same command appearing repeatedly
Same command appearing repeatedly
- Identify the calling application
- Check for inefficient loops or queries
- Consider caching results
- Optimize the command or data structure
KEYS command in slow log
KEYS command in slow log
- Replace with SCAN command
- KEYS blocks the server during execution
- Never use KEYS in production code
- Consider using key naming conventions for SCAN patterns
Large collection commands slow
Large collection commands slow
- Use SCAN variants (SSCAN, HSCAN, ZSCAN)
- Paginate with LIMIT when possible
- Consider breaking large collections into smaller ones
- Check if all data is actually needed
Write commands appearing slow
Write commands appearing slow
- Check persistence settings (AOF fsync)
- Monitor disk I/O
- Large values take longer to write
- Check replication lag if using replicas
FAQ
What counts as execution time?
What counts as execution time?
Execution time measures only the time Redis spends processing the command. It does not include network latency, client queue time, or time waiting for slow log recording.
Does the slow log impact performance?
Does the slow log impact performance?
Minimal impact. The slow log is stored in memory with a fixed size limit. Recording entries is fast. Very high-traffic systems with
slowlog-log-slower-than 0 may see slight overhead.How long are entries retained?
How long are entries retained?
Entries are kept until the log reaches
slowlog-max-len entries. Oldest entries are removed when new ones are added. The log is also cleared on server restart.Why is my fast command in the slow log?
Why is my fast command in the slow log?
The default threshold is 10ms. Commands just over this appear in the log. During high load, normally fast commands may slow down due to queueing or CPU contention.
Can I export slow log data?
Can I export slow log data?
Use
SLOWLOG GET <count> in Redis CLI to retrieve entries. The UI displays entries for analysis; use CLI for programmatic export.What's a good threshold for production?
What's a good threshold for production?
Start with the default 10ms. Adjust based on your latency requirements. For real-time applications, consider 1-5ms. For batch processing, 50-100ms may be acceptable.
Why is SCAN not a complete solution for KEYS?
Why is SCAN not a complete solution for KEYS?
SCAN is non-blocking and cursor-based, so it doesn’t freeze Redis. However, scanning millions of keys still takes time. Use specific patterns and limit result sets.
How do I identify which application is causing slow commands?
How do I identify which application is causing slow commands?
Use CLIENT SETNAME in your applications to set descriptive client names. The slow log will show these names, making it easy to trace commands to specific services.
Best Practices
Monitoring
- Review slow log regularly, not just during incidents
- Set up alerts for unusual slow log growth
- Track common slow commands over time
- Compare slow log patterns after deployments
Threshold Tuning
- Start with defaults, adjust based on requirements
- Lower threshold during optimization efforts
- Raise threshold if log fills too quickly
- Consider different thresholds for different environments
Command Optimization
- Replace KEYS with SCAN patterns
- Use pipeline for multiple commands
- Paginate large collection reads
- Consider data structure changes for frequent slow operations
Application Design
- Set CLIENT SETNAME for each service
- Cache frequently accessed data
- Batch operations when possible
- Monitor client-side latency alongside slow log