Scrivio Interview library
ConceptFoundations5 min read · updated 13 November 2026

Redis keeps a slow log of commands whose execution took longer than a threshold. It is the first tool people reach for when Redis looks slow, and it is often misread.

What exactly does SLOWLOG record, how is it configured, and what kinds of slowness will it never show?

SLOWLOG records commands whose execution on the main thread took longer than slowlog-log-slower-than microseconds (10,000, which is 10 ms, by default), keeping the last slowlog-max-len entries (128 by default) in memory, each with an id, timestamp, duration, the command and its arguments, and the client address and name. It measures only execution, so it never shows time spent queued behind other commands, network transfer, fork pauses, fsync stalls, swapping or client-side delays.

Why this question is asked

When Redis looks slow, almost everyone runs SLOWLOG GET first, and when it comes back empty, many conclude that Redis is fine. That conclusion is often wrong, and interviewers ask about SLOWLOG precisely to see whether we know what it measures and what it cannot see. In this answer, we will recap where a command's time goes, look at what SLOWLOG records and how to configure it, read real entries, and then list the kinds of slowness it will never show and where to look for them instead.

1A Quick Recap: Where a Command's Time Goes

From the client's point of view, a Redis call has several phases. The request travels over the network. It waits in the socket until the event loop reads it, which may mean waiting behind other clients' commands. Redis parses it, executes it, and puts the reply in an output buffer. The reply travels back over the network, and the client library hands it to the application thread.

SLOWLOG times exactly one of these phases: execution. Everything before and after is invisible to it. That single fact explains most misreadings.

Step throughPhases of one Redis call
  1. Client sends requestnetwork, TLS, client pool waits
  2. Waits to be readqueued behind other clients' commands
  3. Read and parsesocket read, RESP parsing
  4. Executethe only phase SLOWLOG measures
  5. Write replyoutput buffer, socket write
  6. Network back to clientthen client library and GC

6 steps in order. Play them, or step through them one at a time.

A call can take 50 ms while its execution takes 5 microseconds.

2What SLOWLOG Records and How to Configure It

slowlog-log-slower-than sets the threshold in microseconds. The default, 10000, means 10 ms; 0 logs every command, and a negative value disables the log. slowlog-max-len sets how many entries are kept, 128 by default. The log is a ring buffer in memory: when it is full, the oldest entry is dropped, and it is lost on restart.

Each entry holds a unique increasing id, the Unix timestamp when the command ran, the execution time in microseconds, the command and its arguments (long argument lists and long strings are truncated), and the client's address and name, if the client set one with CLIENT SETNAME.

Java
CONFIG SET slowlog-log-slower-than 2000 -- log commands slower than 2 ms
CONFIG SET slowlog-max-len 1024
SLOWLOG GET 2
1) 1) (integer) 4721 -- id
2) (integer) 1762951042 -- Unix timestamp
3) (integer) 38114 -- 38 ms of execution
4) 1) "HGETALL" 2) "cart:{u:88213}" -- command and arguments
5) "10.4.2.17:52110" -- client address
6) "cart-service" -- client name
2) 1) (integer) 4720
...
SLOWLOG LEN -- (integer) 37
SLOWLOG RESET -- OK, clears the log

Notice the client name in the last field. If every service sets a name on its connections, a slow log entry points straight to the service that sent it.

3What SLOWLOG Will Never Show

Because it times only execution, SLOWLOG misses time spent waiting behind other commands. If one command takes 30 ms, it appears in the log, but the hundreds of fast commands that waited behind it do not, even though their clients saw 30 ms of extra latency. Equally, many commands of 1 to 5 ms each, below a 10 ms threshold, can keep the server busy and queue everyone without ever being logged.

It also misses everything outside the execution step: reading the request and writing the reply, network transfer, and the time a large reply takes to drain. It never records fork pauses from BGSAVE or AOF rewrite, AOF fsync stalls on a slow disk, page faults when Redis is swapping, slow clients that read replies late, or problems in the network. And on the client side it cannot see waiting for a connection from a pool, a busy client event loop, or JVM garbage collection pauses that make a Redis call look slow.

Where to look when SLOWLOG is empty
Cause of slownessSeen by SLOWLOG?Where to look instead
One O(N) commandyesSLOWLOG GET
Queueing behind other commandsnoINFO latencystats, client p99
Fork for BGSAVE or AOF rewritenoLATENCY LATEST, latest_fork_usec
AOF fsync stall, swappingnoLATENCY DOCTOR, logs, host metrics
Network, TLS, large repliesnoredis-cli --latency from the client host
Pool waits, GC, client threadsnoclient metrics, GC logs

4A Practical Setup

The 10 ms default is too high for most applications, where a normal command takes microseconds and a 2 ms command already matters. A threshold of 1000 to 5000 microseconds catches the commands that hurt, and a larger max length, such as 512 or 1024, keeps enough history to cover an incident.

Because the log is a ring buffer, entries from last night's incident may be gone by the morning. A monitoring agent should read SLOWLOG GET regularly, export new entries by id to the logging system, and keep them for weeks. Combined with client names, that gives a searchable history of slow commands per service.

5Follow-up questions

Why does one slow command raise latency for every client?

Because commands execute one at a time on the main thread. While a 30 ms command runs, the event loop cannot serve any other client, so every request that arrives during those 30 ms waits. Their own execution is still microseconds, so they never appear in SLOWLOG, but their clients see up to 30 ms of extra latency.

Does SLOWLOG include the time a blocking command such as BLPOP waits?

No. A blocked client is parked without using the main thread, and the time it waits for data is not execution time. Only the actual work when the command runs is measured.

Is it safe to set the threshold to 0?

Briefly, on a test instance, it is useful for seeing every command. In production it fills the ring buffer within milliseconds and adds a little overhead to every command, so it gives little useful history.

6Conclusion

In this answer, we saw that SLOWLOG records commands whose execution exceeded slowlog-log-slower-than, 10 ms by default, in an in-memory ring buffer of slowlog-max-len entries, each with an id, timestamp, duration, arguments and client details. Because it measures only execution on the main thread, it never shows queueing, network transfer, fork pauses, fsync stalls, swapping or client-side delays, so an empty slow log does not mean Redis is fast for clients. A lower threshold, a longer log and export to monitoring make it far more useful.

What to say in the interviewAbout 80 seconds aloud

Open with

SLOWLOG records commands whose execution time is above slowlog-log-slower-than, in microseconds, with a default of 10000, so 10 ms. It keeps the last slowlog-max-len entries, 128 by default, in memory as a ring buffer.

Then, if they want more

Each entry has an id, a Unix timestamp, the duration in microseconds, the command with its arguments, truncated if long, and the client address and name. I read it with SLOWLOG GET 20 and clear it with SLOWLOG RESET. The key point is that it measures only execution on the main thread.

It does not include the time a command waited behind other commands, reading the request, network transfer or writing the reply. So it never shows fork pauses, AOF fsync stalls, swapping, slow clients, network problems, or client-side delays like connection pool waits and GC pauses.

That is also why one slow command hurts everyone: the commands queued behind it are fast to execute and never logged, but their clients feel the wait.

In practice I set the threshold to 1 to 5 ms, raise the max length to several hundred, make services set client names, and export entries to monitoring so they outlive the ring buffer.

About this answer

Last updated
13 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
Redis documentation
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "What exactly does SLOWLOG record, how is it configured, and what kinds of slowness will...": https://scrivio-interview-library.netlify.app/databases/redis-internals/23c574a8ad/