Quick revision
The short answer
First I would find out whether the main thread is spending its time on commands or on socket work, because the fixes differ. I would take the cheap wins right away, and since three times the load will not fit one primary if command execution dominates, I would start splitting sessions and carts onto separate primaries or a cluster now. I would prove it with a load test at about 3.5 times peak on production-sized data, including a failover, judged by latency percentiles, and plan the event day with alerts and degradation steps.
What to remember
In this answer, we saw that three times the load cannot fit one main thread already at 85 percent unless most of the work is removed, so we measure first with commandstats, latencystats and the CPU split, take the cheap wins of removing and batching commands and enabling I/O threads, and start splitting primaries early because that is the slow part. We prove the result with a 3.5 times load test on realistic data, including a failover and judged by percentiles, and we plan the day with a freeze, alerts and written degradation steps.
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.
First I would find out whether the main thread is spending its time on commands or on socket work, because the fixes differ. I would take the cheap wins right away, and since three times the load will not fit one primary if command execution dominates, I would start splitting sessions and carts onto separate primaries or a cluster now. I would prove it with a load test at about 3.5 times peak on production-sized data, including a failover, judged by latency percentiles, and plan the event day with alerts and degradation steps.
Why this question is asked
Capacity questions with a deadline are common in senior interviews because they test judgement more than knowledge. Anyone can say add a cluster; the skill is knowing what to measure first, which changes are cheap and safe, which are expensive and need a head start, and how to show the business that the system will hold rather than hoping it will. In this answer, we will measure the current load, take the cheap wins, do the arithmetic for three times the load, plan the scale-out, design a load test that actually proves something, and prepare for the day itself.
1Doing the Arithmetic First
Today the primary peaks at 85 percent of one core. If load scaled linearly, three times the peak would need 255 percent of one core, and a Redis main thread can never use more than 100 percent. Even a 50 percent saving from optimisation would leave us at about 128 percent. So the honest starting point is that the current shape probably does not fit, and the real question is how much of the 85 percent we can remove and how much capacity we must add.
Six weeks sounds like a lot, but a migration to more primaries needs client changes, testing, a rehearsal and a cutover, which easily uses four of those weeks. That is why the measurement has to happen in the first days, not the last.
2Finding What the Main Thread Spends Time On
INFO commandstats lists every command with its call count and usec_per_call, so we can multiply them and see which commands consume the most execution time. INFO latencystats gives per-command percentiles. Comparing used_cpu_sys with used_cpu_user tells us whether the time goes to commands or to socket syscalls. Connection counts and payload sizes, from INFO clients and network counters, complete the picture.
The result usually falls into one of two shapes. If system CPU dominates and commands are tiny, the load is syscall-bound, and I/O threads plus batching can give a large gain. If a few commands, such as HGETALL on large carts or session reads that return big blobs, dominate usec_per_call times calls, the load is command-bound, and only fewer or cheaper commands, or more main threads, will help.
- Measurecommandstats, latencystats, sys vs user CPU, connections, payload sizes
- Mostly syscall-bound?YesI/O threads and batching firstNoreduce and cheapen commands
- Apply cheap winsremove waste, bound O(N) reads, local caching
- Projected 3x load under ~60 percent of a core?Yeskeep one primary, load testNosplit primaries now
- Load test at 3.5x with a failoverjudge by p99 and p999
5 steps in order. Play them, or step through them one at a time.
The second decision is the one that needs a head start.
3Taking the Cheap Wins
Before any architecture change, remove work. Typical findings are reads of a whole cart with HGETALL when the page needs only the item count, a session refresh with EXPIRE on every request where once a minute would do, and EXISTS before GET. Each of these is a small code change with a measurable effect in commandstats.
Next, batch. A page that makes six Redis calls can usually make one pipeline or one MGET. If socket work dominates, enable I/O threads. And cache hot, read-only values in the application for a few seconds, for example the promotion configuration that every request reads, so they stop reaching Redis at all.
4Adding Main Threads Before the Day
If command execution still dominates, we need more primaries. The simplest split for this platform is by use case: sessions on one primary, carts on another. Each gets its own main thread, the change in the application is a second connection factory, and no data needs resharding inside a use case. If one use case alone exceeds a core, Redis Cluster spreads it across many primaries.
Cluster brings its own work. Clients must be cluster-aware, multi-key commands and Lua scripts only work when all keys are in one slot, which means designing hash tags such as cart:{user42}:items, and the migration must be rehearsed, usually by dual-writing or by letting short-lived session keys refill on the new store. That is the work that needs to start this week, not in week five.
5Proving It With a Load Test
A load test proves something only if it resembles the real day. That means production-sized data (the same number of keys and value sizes, since memory layout changes performance), a realistic mix of commands taken from commandstats, the real client libraries and connection settings, and a target of about 3.5 times today's peak so we have margin above the forecast.
We should judge it by latency percentiles, p99 and p999, at the client, not by throughput alone, because a saturated Redis keeps its throughput while its latency explodes. And we should fail over a primary in the middle of the test, because a failover during the event is a real possibility, and we need to know how long clients take to reconnect and how far latency rises meanwhile.
6Planning the Event Day
On the day, the plan is mostly about not adding risk. Freeze risky deployments around the event, set alerts on main-thread CPU (for example 70 percent) and on client p99, and assign people who know the runbook. Then write the degradation steps down in advance: which non-critical keys we can stop writing (recommendation caches, analytics counters), which local caches we can extend from 5 to 30 seconds, and who is allowed to flip those switches. When saturation comes, a decision made weeks earlier is far better than one made during an incident.
7Follow-up questions
Which metric would make you call off the event-day launch?
I would agree a threshold with the business in advance, based on the load test: for example, if client-side p99 for session reads stays above 5 ms for five minutes, or main-thread CPU stays above 90 percent with growing p999, we stop the next wave of traffic, such as delaying a marketing push, and apply the degradation steps. Throughput alone would not trigger it, because it looks healthy until the queue builds.
Why not just use replicas for the extra read load?
Sessions and carts are read and written by the same user within milliseconds, so a replica read can return a cart that is missing the item just added. Replicas also do nothing for write load. They are useful for read-mostly data with tolerant consumers, which is not this case.
What if the load test shows we cannot be ready in time?
Then we say so early, and choose among reducing scope, such as keeping recommendations off Redis for the day, buying time with application caching, or limiting entry with a queue page. A clear statement in week two is far more useful than an outage in week six.
8Conclusion
In this answer, we saw that three times the load cannot fit one main thread already at 85 percent unless most of the work is removed, so we measure first with commandstats, latencystats and the CPU split, take the cheap wins of removing and batching commands and enabling I/O threads, and start splitting primaries early because that is the slow part. We prove the result with a 3.5 times load test on realistic data, including a failover and judged by percentiles, and we plan the day with a freeze, alerts and written degradation steps.
Open with
I would start with the arithmetic: 85 percent of one core times three is well over a core, and the main thread cannot exceed one, so optimisation alone probably will not do it.
Then, if they want more
In the first days I would measure what the main thread spends time on, using commandstats for calls times usec_per_call, latencystats, used_cpu_sys versus used_cpu_user, connection counts and payload sizes, because syscall-bound and command-bound load need different fixes.
Then I take the cheap wins: remove wasted calls, pipeline or batch, replace HGETALL-style reads with bounded ones, cache hot read-only data in the application, and enable I/O threads if socket work dominates.
In parallel I start splitting sessions and carts onto separate primaries, or a cluster if one use case needs it, because that needs client changes, hash tags for multi-key operations and a rehearsed migration, and six weeks is not much.
To prove it I would load-test at about 3.5 times peak with production-sized data and the real command mix, fail over a primary during the test, and judge by p99 and p999 rather than throughput. For the day itself: a deployment freeze, CPU and latency alerts, and written degradation steps such as shedding non-critical keys and extending local caches.
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 "How do you decide what to change before the event, and how do you prove that the system...": https://scrivio-interview-library.netlify.app/databases/redis-internals/29bbbf50a6/