Quick revision
The short answer
Little's law says the average number of calls in flight equals the arrival rate times the average latency: 500 requests per second times 0.2 seconds gives 100 concurrent blocking calls, so the pool needs at least 100 threads, plus margin for latency spikes, and it must stay bounded so a slow downstream cannot exhaust memory. Blocking pools are sized by needed concurrency, while CPU-bound pools stay near the core count, and each downstream gets its own pool as a bulkhead. With virtual threads we stop sizing a pool, but we still need a limit, such as a Semaphore, to protect the downstream.
What to remember
In this answer, we used Little's law to size a blocking pool: 500 requests per second times 200 ms means 100 calls in flight on average, so we start around 150 to 200 threads after allowing for latency variance, keep the pool and its queue bounded so a slowdown causes fast rejections instead of memory exhaustion, size CPU pools near the core count, and give each downstream its own pool as a bulkhead. With virtual threads there is no pool to size, but the downstream still needs an explicit limit, such as a Semaphore with a bounded wait.
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.
Little's law says the average number of calls in flight equals the arrival rate times the average latency: 500 requests per second times 0.2 seconds gives 100 concurrent blocking calls, so the pool needs at least 100 threads, plus margin for latency spikes, and it must stay bounded so a slow downstream cannot exhaust memory. Blocking pools are sized by needed concurrency, while CPU-bound pools stay near the core count, and each downstream gets its own pool as a bulkhead. With virtual threads we stop sizing a pool, but we still need a limit, such as a Semaphore, to protect the downstream.
Why this question is asked
Thread pool sizes are often chosen by copying a number from another service, and the result is either a pool that queues under normal load or one so large that a downstream slowdown takes the whole service down. A short calculation gives a much better starting point, and interviewers like this question because it combines that calculation with failure thinking and the newer virtual-thread model. In this answer, we will recap Little's law, apply it to the numbers in the question, add margin for variance, contrast blocking and CPU pools, use bulkheads per downstream, and see what changes and what stays the same with virtual threads.
1A Quick Recap of Little's Law
Little's law is a simple, general rule from queueing theory: in a stable system, the average number of items inside it equals the rate at which items arrive multiplied by the average time each item spends inside. It does not depend on the distribution of arrivals or the type of work. A coffee shop that serves 60 customers an hour, each staying 30 minutes, has on average 60 x 0.5 = 30 customers inside.
For a thread pool making blocking calls, the items are calls in flight and the time inside is the call's latency. Each call occupies one thread for its whole duration, because a platform thread waiting on a socket can do nothing else. So the number of threads we need equals the number of calls in flight.
2Applying It to 500 Requests per Second
With 500 requests per second and 0.2 seconds per downstream call, the average concurrency is 500 x 0.2 = 100. A pool with fewer than 100 threads cannot keep up even on an average second: with 80 threads, it completes at most 80 / 0.2 = 400 calls per second, so 100 requests per second pile up in the queue and latency grows without bound.
An average is not enough, because latency varies. If the downstream's 99th percentile is 600 ms, then during a bad second concurrency can approach 500 x 0.6 = 300. Traffic also has peaks above the average rate. A reasonable starting point is the average concurrency times a safety factor based on measured latency percentiles, for example 150 to 200 threads with a short bounded queue, and then load testing to confirm.
| Downstream latency | Calls in flight | What a 200-thread pool does |
|---|---|---|
| 200 ms (average) | 100 | Keeps up with half the threads idle |
| 600 ms (p99 spell) | 300 | Queue absorbs a short spell, then rejects |
| 2,000 ms (incident) | 1,000 | Rejects most requests fast; memory stays bounded |
Notice that we do not size for the worst case. If the downstream slows to 2 seconds per call, Little's law says we would need 1,000 threads. Giving it 1,000 threads would not make the downstream faster; it would only let us hold 1,000 requests and their memory while the downstream struggles. So the pool is bounded on purpose, the queue is short, and when both are full the extra requests are rejected quickly with an error, which protects the service and gives the downstream room to recover.
3Blocking Pools Versus CPU-Bound Pools
The calculation above applies to threads that mostly wait. CPU-bound work, such as parsing, compression or image resizing, is different: a thread doing computation needs a core, and more threads than cores only adds context switching. CPU pools are therefore sized near the number of cores, Runtime.getRuntime().availableProcessors(), perhaps plus one. A blocking pool on an 8-core machine can sensibly have 200 threads because 190 of them are waiting on the network at any moment.
Mixing the two in one pool causes trouble: during a downstream slowdown, blocking calls occupy every thread and the CPU work starves, or the CPU work is starved of cores by too many runnable threads. Keeping them in separate pools makes each one's size a clear decision.
4One Pool per Downstream: Bulkheads
A bulkhead is a partition that keeps a failure in one compartment from flooding the others, named after the walls inside a ship's hull. If our service calls a pricing service and an inventory service from one shared pool of 200 threads, a pricing slowdown fills all 200 threads with waiting pricing calls, and inventory calls, which were perfectly healthy, can no longer run. With separate pools, for example 120 threads for pricing and 80 for inventory, each sized with Little's law from its own rate and latency, a pricing incident exhausts only the pricing pool. Requests that need only inventory still succeed, and the service degrades partly instead of completely.
5What Changes With Virtual Threads
Virtual threads, final since Java 21, are threads managed by the JVM rather than the operating system. When a virtual thread blocks on I/O, the JVM unmounts it from its carrier, the platform thread that runs it, and the carrier runs another virtual thread. They cost a few hundred bytes to a few kilobytes each instead of a megabyte of reserved stack, so creating one per request is fine. There is no pool to size: we use a new virtual thread for each task, and blocking costs almost nothing.
But the limit did not disappear; it moved. A thread pool used to limit concurrency as a side effect. With virtual threads, 500 requests per second against a downstream that slows to 2 seconds would create 1,000 concurrent calls, then more, and the downstream, its connection pool or our memory becomes the bottleneck. So we add the limit explicitly: a Semaphore with, say, 150 permits around calls to that downstream, sized with the same Little's law reasoning, and a short wait to acquire so excess requests fail fast. The semaphore is now our bulkhead. The HTTP client's connection pool and timeouts still matter as before. In Spring Boot 3.2 and later, spring.threads.virtual.enabled=true runs request handling on virtual threads, which makes these explicit limits even more important.
6Follow-up questions
Do virtual threads help CPU-bound work?
No. They help when threads wait. CPU-bound work still needs cores, and the virtual-thread scheduler has by default as many carriers as cores, so CPU work should still go to a pool sized near the core count.
How do you verify the chosen size?
With a load test at realistic and peak rates while measuring active threads, queue depth, latency percentiles and rejections, and then injecting downstream latency, for example with a fault proxy, to see that the bulkheads hold and that the service rejects quickly instead of running out of memory.
Why not just use a very large queue instead of more threads?
Because queued requests wait while their clients time out. A queue holding 10,000 requests at 400 completions per second means 25 seconds of waiting, long past any client timeout, so the service would do work nobody is waiting for. Short queues and fast rejection give clients a quick answer they can retry.
7Conclusion
In this answer, we used Little's law to size a blocking pool: 500 requests per second times 200 ms means 100 calls in flight on average, so we start around 150 to 200 threads after allowing for latency variance, keep the pool and its queue bounded so a slowdown causes fast rejections instead of memory exhaustion, size CPU pools near the core count, and give each downstream its own pool as a bulkhead. With virtual threads there is no pool to size, but the downstream still needs an explicit limit, such as a Semaphore with a bounded wait.
Open with
I would start with Little's law: average concurrency equals arrival rate times latency, so 500 requests per second times 0.2 seconds is 100 calls in flight on average.
Then, if they want more
Each blocking call holds a platform thread, so fewer than 100 threads cannot even keep up with the average and the queue grows forever. Latency varies, so I would look at percentiles: at a p99 of 600 milliseconds the concurrency can reach 300.
I would pick something like 200 threads with a short bounded queue and confirm with a load test. I would not size for the worst case, because if the downstream slows to two seconds, a thousand threads would just hold a thousand requests in memory; I want fast rejection instead.
Blocking pools are sized by concurrency, but CPU-bound pools stay near the core count, and I keep them separate. I would also give each downstream its own pool as a bulkhead, so a slow pricing service cannot take the threads that inventory calls need.
With virtual threads I do not size a pool at all: each request gets a cheap virtual thread and blocking is nearly free.
But the pool used to limit concurrency as a side effect, so I add the limit explicitly, for example a Semaphore of 150 permits around the downstream call with a short tryAcquire timeout, so excess requests fail fast.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- Java 21, Spring Boot 3.2
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the official documentation for the version you use. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
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 "A service receives 500 requests per second, and each request makes a blocking call to a...": https://scrivio-interview-library.netlify.app/java/concurrency-patterns/54eeaa43e9/