Redis slowlog Explained: Monitoring and Troubleshooting Slow Commands

Published: 2026-07-17

Introduction

The Redis Slow Log is a built-in performance monitoring feature that records commands taking longer than a specified execution time.

Unlike traditional log files, the Slow Log does not measure network latency or client communication. Instead, it records the time Redis spends executing commands internally.

Monitoring the Slow Log helps administrators identify inefficient queries, large key operations, and commands that may reduce overall server performance.

This guide explains how Redis Slow Log works, how to configure it, and best practices for analyzing slow commands.

What Is the Slow Log?

The Slow Log records commands whose execution time exceeds a configured threshold.

For example, if the threshold is:

slowlog-log-slower-than 10000

Redis records commands that take longer than:

10,000 microseconds (10 milliseconds)

Fast commands are ignored.

Related Configuration

Redis provides two settings for the Slow Log.

Execution time threshold:

slowlog-log-slower-than 10000

Maximum number of stored entries:

slowlog-max-len 128

How the Slow Log Works

When a command finishes executing:

Redis measures the execution time.

The duration is compared with slowlog-log-slower-than.

If the threshold is exceeded, Redis stores the command in the Slow Log.

Older entries are removed automatically when the maximum length is reached.

View Slow Log Entries

Display recent entries:

redis-cli SLOWLOG GET

Limit the number of results:

redis-cli SLOWLOG GET 10

Example output:

1) 1) (integer) 15

2) (integer) 1751000000

3) (integer) 15874

4) 1) "KEYS"

2) "*"

The execution time is reported in microseconds.

Check the Number of Entries

Run:

redis-cli SLOWLOG LEN

Example:

(integer) 35

Clear the Slow Log

Delete all entries:

redis-cli SLOWLOG RESET

Example output:

OK

Configure the Slow Log

Open the Redis configuration file.

sudo nano /etc/redis.conf

Example:

slowlog-log-slower-than 10000

slowlog-max-len 256

Restart Redis.

sudo systemctl restart redis

Choosing the Right Threshold

| Threshold | Meaning           | Typical Use             |
| --------- | ----------------- | ----------------------- |
| -1        | Disable Slow Log  | Rarely recommended      |
| 0         | Log every command | Debugging only          |
| 1000      | 1 ms              | Performance testing     |
| 10000     | 10 ms             | General production      |
| 50000     | 50 ms             | Busy production servers |

For most environments, 10 milliseconds is a reasonable starting point.

Common Slow Commands

Commands frequently appearing in the Slow Log include:

KEYS

SORT

SMEMBERS

HGETALL

ZRANGE

SUNION

These commands can become expensive when operating on very large datasets.

Common Mistakes

Using KEYS in Production

KEYS *

This command scans the entire keyspace and may block Redis on large databases.

Prefer:

SCAN

Ignoring Large Keys

Large hashes, lists, sets, or sorted sets can significantly increase command execution time.

Regularly review key sizes and memory usage.

Logging Every Command

Setting:

slowlog-log-slower-than 0

records every command and can generate excessive monitoring data.

Use this only for temporary debugging.

Best Practices

Leave the Slow Log enabled in production.

Start with a threshold of 10 ms and adjust based on workload.

Review Slow Log entries regularly.

Replace KEYS with SCAN in large databases.

Investigate commands that appear repeatedly.

Combine Slow Log analysis with INFO and MONITOR for deeper performance insights.

Related Articles

Redis Explained

Redis logfile Explained

Redis loglevel Explained

Redis key management Explained

Redis maxmemory Explained

Conclusion

The Redis Slow Log is an essential diagnostic tool for identifying commands that consume excessive execution time. By recording only commands that exceed a configurable threshold, it helps administrators focus on performance bottlenecks without overwhelming the logging system.

For most production deployments, enabling the Slow Log with a threshold of 10 milliseconds provides valuable insight into application performance while keeping monitoring overhead low.

Explore More

Technology Guides →

Redis INFO Explained: Monitoring Redis Server Statistics

Redis maxmemory Explained: How to Limit Memory Usage and Prevent OOM Errors

Redis maxmemory-policy Explained: Choosing the Right Eviction Policy

Redis appendonly Explained: Understanding AOF Persistence

Southeast Asia Insights →

Why Do People in Southeast Asia Love Iced Drinks? The Climate, Culture, and Science Explained

Northern vs Southern Chinese Business Culture: Key Differences Explained