Quick revision
The short answer
The bottleneck is socket work, not command execution: with 160,000 tiny operations per second from 4,000 connections, the main thread spends its time in read and write system calls and protocol handling, which shows up as system CPU, and SLOWLOG stays empty because it only times execution. I would first enable I/O threads, then cut the number of syscalls per operation with pipelining, multi-key commands and fewer connections, measuring after each step, and shard the keyspace only if one primary is still at its limit.
What to remember
In this answer, we saw that a saturated main thread with growing system CPU and an empty SLOWLOG means the cost is in socket syscalls and protocol work, not in commands. The fix, in order, is to enable I/O threads with a moderate count, reduce syscalls with pipelining, multi-key commands, fewer connections and fewer useless calls, measure each step with production metrics, and shard to more primaries only if one main thread is still not enough.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
The bottleneck is socket work, not command execution: with 160,000 tiny operations per second from 4,000 connections, the main thread spends its time in read and write system calls and protocol handling, which shows up as system CPU, and SLOWLOG stays empty because it only times execution. I would first enable I/O threads, then cut the number of syscalls per operation with pipelining, multi-key commands and fewer connections, measuring after each step, and shard the keyspace only if one primary is still at its limit.
Why this question is asked
This is a classic production puzzle: Redis is clearly overloaded, yet every tool that measures slow commands says everything is fine. Interviewers use it to see whether we know what the main thread actually spends its time on, and whether we can fix a capacity problem in a sensible order instead of jumping straight to a cluster migration. In this answer, we will read the evidence, explain why the system CPU grows, and then go through the changes in the order I would make them, with the measurement after each one.
1Reading the Evidence
INFO cpu reports two counters for the main process: used_cpu_user, time spent running Redis's own code, and used_cpu_sys, time spent inside the kernel on Redis's behalf. Executing GET and SET is user time. Reading a request from a socket and writing a reply back is mostly system time, because each one is a system call that crosses into the kernel and touches the network stack.
So when used_cpu_sys grows faster than used_cpu_user, the thread is spending more effort talking to sockets than running commands. With 160,000 operations per second, each one a small request and a small reply, that is hundreds of thousands of read and write calls per second on one core, and the core reaches 100 percent.
SLOWLOG confirms the picture rather than contradicting it. It only records the time a command spends executing, after it was parsed and before the reply is written. A GET takes about a microsecond, far below the 10 ms default threshold, so nothing is ever logged. The 6 ms p99 is time requests spend waiting in the queue for the one busy thread.
| Signal | Value here | Meaning |
|---|---|---|
| One core at 100 percent | yes | the main thread is saturated |
| used_cpu_sys vs used_cpu_user | sys grows faster | time goes to syscalls and socket work |
| SLOWLOG | empty | no single command is slow to execute |
| p99 latency | 0.4 ms -> 6 ms | requests queue behind the busy thread |
2Turn On I/O Threads
I/O threads exist for exactly this case. They take reading, parsing and reply writing off the main thread, so the main thread only executes commands. On a 16-vCPU host, io-threads 4 to 6 is a reasonable start, which leaves cores for the operating system's network processing, background threads and any fork. More is rarely better, because the threads hand work back and forth with the main thread.
Redis 8 and Valkey 8 reworked the threading model, and in those versions the threads read and parse as well without a separate switch, so check your version's settings. The gain is often large, but it is not linear: four threads do not give four times the throughput, because every command still passes through the main thread, which remains the ceiling.
3Cut Syscalls per Operation
The cheapest syscall is the one we never make. If the application sends ten GETs one by one, that is ten requests and ten replies. If it sends one MGET with ten keys, or pipelines the ten GETs, the work for Redis is almost the same but the socket work is about a tenth. Pipelining and MGET or MSET are therefore the most effective change, but they need code changes in the clients.
The connection count matters too. 4,000 connections usually means many pods each holding a large pool. Lettuce, the default client in Spring Boot, multiplexes all commands from one application over a single shared connection per Redis node, and it naturally batches commands written close together. Moving from large Jedis pools to Lettuce, or shrinking the pools, reduces the number of sockets Redis polls and the memory for their buffers.
Finally, look for calls that do nothing useful. A common one is EXISTS followed by GET: the GET already tells us whether the key exists, so the EXISTS doubles the traffic for no gain. INFO commandstats shows the call counts per command, and an unexpectedly high count for EXISTS, TTL or PING is a good hint.
4Measure After Each Change
Each change should be made alone and measured in production, because we want to know which one helped. The metrics are instantaneous_ops_per_sec, the per-command percentiles in INFO latencystats (available from Redis 7.0), CPU per thread from the host (top -H shows the main thread and the io_thd threads separately), and the client-side p99 that users actually feel.
A good result looks like this: the main thread drops from 100 percent to around 60 percent, used_cpu_sys falls relative to used_cpu_user, and p99 returns towards half a millisecond. That remaining headroom tells us how much growth we can absorb.
5Shard When One Primary Is Not Enough
If the primary is still near its limit after these changes, the next step is more primaries: Redis Cluster, or splitting the keyspace by use case across separate instances. That adds main threads, which is the only way to add command-execution capacity. Replicas can take some reads, but only where slightly stale data is acceptable, because replication is asynchronous. I would leave this step last because it changes clients, multi-key commands and operations, while the first three steps are configuration or small code changes.
6Follow-up questions
Why can thousands of idle connections still cost CPU and memory?
Each connection has a client structure, a query buffer and an output buffer, often tens of kilobytes even when idle, so 4,000 connections can cost a hundred megabytes or more. Clients also send periodic PINGs or health checks, the event loop must track every socket, and client timeout checks walk the list. And when a burst of reconnects happens, for example after a deploy, the accept calls and TLS handshakes land on the main thread all at once.
Would adding a replica for reads solve the problem?
Partly, if the application can accept reads that lag by a few milliseconds and the clients are configured to read from replicas. It does not help writes, which must all go to the primary, and it adds replication traffic to the primary. It is a valid step, but it is not a substitute for reducing syscalls.
How do I know I/O threads are actually being used?
Look at per-thread CPU on the host: with threads working, the io_thd threads show CPU and the main thread drops. INFO in Redis 7 also reports io_threads_active, which is 1 only when Redis decided the load is high enough to use them; at low load it keeps them idle.
7Conclusion
In this answer, we saw that a saturated main thread with growing system CPU and an empty SLOWLOG means the cost is in socket syscalls and protocol work, not in commands. The fix, in order, is to enable I/O threads with a moderate count, reduce syscalls with pipelining, multi-key commands, fewer connections and fewer useless calls, measure each step with production metrics, and shard to more primaries only if one main thread is still not enough.
Open with
The commands are cheap, so SLOWLOG, which only measures execution time, has nothing to record. High system CPU tells me the main thread is spending its time in read and write syscalls and RESP parsing for 160,000 tiny requests from 4,000 sockets, and the p99 rise is queueing behind that one thread.
Then, if they want more
First I would enable I/O threads, around io-threads 4 to 6 on 16 vCPUs so the OS and background work keep some cores, and on 7.2 also io-threads-do-reads yes; on Redis 8 or Valkey 8 the threading changed, so I would check the version's settings.
Second, I would cut syscalls per operation: pipeline or use MGET and MSET, move from big connection pools to Lettuce's shared multiplexed connection, and remove pointless calls like EXISTS before GET, which I can spot in commandstats. After each change I measure instantaneous_ops_per_sec, latencystats percentiles and per-thread CPU, knowing I/O threads help a lot but not linearly.
If the primary is still near its limit, I shard across more primaries, and only use replicas for reads where slightly stale data is fine.
About this answer
- Last updated
- 13 November 2026
- Versions it names
- Redis 7, Redis 8
- 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 "INFO cpu shows used_cpu_sys growing faster than used_cpu_user, and SLOWLOG is empty....": https://scrivio-interview-library.netlify.app/databases/redis-internals/3bc292404b/