Scrivio Interview library
DebuggingIntermediate6 min read · updated 13 November 2026

A Spring Boot service using Lettuce reports Redis p99 latency of 45 ms in its metrics. On the server, SLOWLOG is empty, CPU is 30 percent, and redis-cli --latency run on the Redis host shows 0.2 ms.

Where can the missing 45 ms come from, and how do you narrow it down?

The missing 45 ms is outside Redis's execution: in the network between the application and Redis, in the client (a large reply or blocking command on Lettuce's shared connection, a busy Netty event-loop thread, JVM GC pauses, or pool waits), or in queueing on the server that SLOWLOG cannot see. I would narrow it down by running redis-cli --latency from an application host, comparing Lettuce's command latency metrics with server-side percentiles from INFO latencystats, checking GC and pool metrics, and looking at LATENCY LATEST for fork or fsync events.

Why this question is asked

This is the most common shape of a Redis latency complaint: the application says Redis is slow, the Redis team says Redis is fast, and both are right about what they measure. Interviewers ask it because solving it needs a method, splitting the path into pieces and timing each one, rather than knowledge of a single setting. In this answer, we will map the path a call takes, test the network, look inside the client, check the server for queueing that SLOWLOG misses, and compare the two sides' metrics to see where the time goes.

1Mapping the Path of One Call

When the service calls redisTemplate.opsForValue().get(key), the time recorded by its metrics covers much more than Redis. The application thread hands the command to Lettuce, which writes it to a connection served by a Netty event-loop thread. The bytes cross the network, possibly through TLS, a load balancer or a proxy, to Redis, where they may wait to be read, are executed, and the reply returns the same way. Lettuce decodes the reply on the event-loop thread and completes the future, and the application thread wakes up.

redis-cli --latency on the Redis host measures only the last hop, from the host to its own Redis, which is why it shows 0.2 ms. SLOWLOG measures only execution. So we have two measurements of the fast part and none of the parts in between. The task is to measure those.

Step throughWhere 45 ms can hide
  1. Application threadGC pauses, thread pool saturation
  2. Lettuce and Nettyshared connection, large replies, busy event loop, pool waits
  3. Networkcross-zone hops, packet loss, TLS reconnects, proxies
  4. Redis event loopqueueing behind other commands, I/O
  5. Redis executionmeasured by SLOWLOG: empty

5 layers, from the top down. Step through them one at a time.

The two measurements we have both sit at the bottom layer.

2Testing the Network From the Application's Side

The first test is simple: run redis-cli --latency and --latency-history from an application host, or from a debug container in the same pod network, against the same Redis endpoint the service uses. --latency sends PING in a loop and prints the minimum, average and maximum round trip; --latency-history prints those numbers every 15 seconds so we can see spikes over time.

Text
# on the Redis host
redis-cli --latency -- min: 0, max: 1, avg: 0.20 (ms)
# from an application node, same endpoint, TLS as the app uses
redis-cli -h redis.prod --tls --latency-history -i 15
-- min: 0, max: 3, avg: 0.95 (1484 samples) -- 15.01 seconds range
-- min: 0, max: 48, avg: 1.10 (1471 samples) -- 15.00 seconds range

If the numbers from the application host are also high or spiky, the network path is the suspect: a hop to another availability zone adds about 0.5 to 2 ms, packet loss causes retransmission delays of tens to hundreds of milliseconds, saturated links queue packets, and TLS handshakes after reconnects add several round trips. If they are as low as on the Redis host, the time is in the client or in the server's queue.

3Looking Inside the Client

Lettuce, the default Redis client in Spring Boot, multiplexes all commands from the application over one connection per Redis node. That is efficient, but it means commands share a single ordered pipe. If one caller sends HGETALL on a hash that returns 20 MB, every command behind it waits until those bytes have arrived. If someone runs a blocking command such as BLPOP on the shared connection, every other command on it waits until BLPOP returns, which is why blocking commands need a dedicated connection.

The Netty event-loop thread that decodes replies can itself be busy, for example if application code runs inside reactive callbacks on that thread, or if decoding large replies takes long. And JVM garbage collection pauses stop every thread: a 40 ms GC pause during a Redis call adds 40 ms to the recorded latency, even though Redis replied in microseconds.

Where connection pools are used, with Jedis or with Lettuce pooling for transactions, the time a thread waits to borrow a connection is part of the measured call. If the pool is too small for the request rate, a thread can wait tens of milliseconds before its command is even sent. Pool metrics such as active connections, waiting threads and maximum wait time show this directly.

4Checking the Server for Hidden Queueing

The server can still be part of the story without SLOWLOG noticing. INFO latencystats (Redis 7.0 and later) reports p50, p99 and p99.9 per command, measured on the server, and INFO commandstats shows usec_per_call. Many commands of 1 to 5 ms each, below the slow log threshold, can run back to back and make other clients queue; that shows as a rise in latencystats percentiles for cheap commands. LATENCY LATEST, with the latency monitor enabled, shows events such as fork or AOF fsync that pause the main thread without any command being slow.

At 30 percent CPU, sustained queueing is unlikely, but short bursts, such as a periodic job, can still produce p99 spikes.

5Comparing Both Sides to Find the Gap

The decisive step is to put the client's view and the server's view side by side. Spring Boot exports Lettuce command latency through Micrometer, timed per command type from when the command is sent to when the reply is complete (metric names vary by Boot and Lettuce version, so check yours). If the Lettuce metric shows 45 ms at p99 for GET and the server's latencystats show 0.05 ms at p99 for GET, the time is between the two: network or Netty. If the Lettuce metric is low but the application's own timer around the call is high, the time is in the application: GC or thread scheduling.

What each comparison tells us
App timerLettuce metricServer latencystatsWhere the time is
45 ms45 ms45 msserver queueing or pauses
45 ms45 ms0.05 msnetwork, TLS, or shared connection
45 ms1 ms0.05 msapplication: GC, pool wait, threads
45 ms45 ms (only some commands)0.05 mslarge replies or blocking commands
Line up the same percentile over the same time window.

6Follow-up questions

How would you prove that a GC pause is the cause?

Enable GC logging with -Xlog:gc*, or use the JVM's GC pause metrics in Micrometer, and line up the pause timestamps with the slow Redis calls in traces or logs. If the slow calls cluster inside GC pauses and the Lettuce metric for those calls is low, GC is the cause. A JFR recording of the incident window shows both safepoint pauses and the threads waiting, which settles it.

Why does a blocking command need its own connection with Lettuce?

Because Lettuce sends all commands of the application over one shared connection in order, a BLPOP that waits ten seconds for data holds that connection, and every command queued behind it waits too. Using a dedicated connection for blocking commands keeps the shared one free.

Could the 45 ms be the client's own timeout and retry?

Yes. If a command times out and Lettuce reconnects or the application retries, the recorded latency includes the timeout plus the retry. Reconnect events in Lettuce's logs and connection counts on the server reveal it.

7Conclusion

In this answer, we saw that SLOWLOG and redis-cli --latency on the Redis host only measure the fast part of the path. Running --latency from an application host tests the network, client-side checks cover Lettuce's shared connection, busy event-loop threads, GC pauses and pool waits, and INFO latencystats and LATENCY LATEST show server queueing and pauses. Comparing the application timer, Lettuce's Micrometer metrics and the server's percentiles over the same window shows exactly where the 45 ms is spent.

What to say in the interviewAbout 80 seconds aloud

Open with

SLOWLOG and redis-cli --latency on the Redis host both measure only the fast part, so the 45 ms is somewhere else. First I run redis-cli --latency and --latency-history from an application host against the same endpoint.

Then, if they want more

If those are also high, I suspect the network path: cross-zone hops, packet loss, a saturated link, or TLS handshakes after reconnects. If they are low, I look at the client.

Lettuce multiplexes everything on one connection per node, so a large reply or a blocking command like BLPOP on the shared connection delays everything behind it, and a busy Netty event-loop thread or long JVM GC pauses also show up as Redis latency.

If a pool is involved, with Jedis or Lettuce pooling for transactions, time spent waiting to borrow a connection is part of the call, so I check pool wait metrics and the maximum size.

On the server I look for queueing that SLOWLOG misses: per-command percentiles in INFO latencystats, many 1 to 5 ms commands back to back, and LATENCY LATEST for fork or fsync events. Finally I compare Lettuce's command latency metrics, which Spring Boot exports through Micrometer, with server-side per-command times, and the gap tells me which side the time is on.

About this answer

Last updated
13 November 2026
Versions it names
Redis 7
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 "Where can the missing 45 ms come from, and how do you narrow it down?": https://scrivio-interview-library.netlify.app/databases/redis-internals/5920d446a0/