Quick revision
The short answer
I would stop treating thread counts as the capacity decision and instead set explicit limits per downstream resource, derived with Little's law from that resource's measured capacity and latency. With virtual threads, threads stop being the limit at all, so those per-resource limits replace pool sizes. Every service publishes the same saturation metrics, limits are reviewed after major traffic or architecture changes rather than only after incidents, and dependencies with variable capacity get adaptive concurrency limits.
What to remember
In this answer, we replaced guessed pool sizes with a fleet-wide way of making capacity decisions. Limits are set per resource from measured capacity and latency with Little's law and divided among callers in a capacity model; virtual threads remove threads as a limit, so explicit per-resource limits take over; every service publishes the same saturation metrics; limits are reviewed after traffic, caller or architecture changes and yearly, not only after incidents; and adaptive limits, inside fixed ceilings, handle dependencies whose capacity varies.
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.
I would stop treating thread counts as the capacity decision and instead set explicit limits per downstream resource, derived with Little's law from that resource's measured capacity and latency. With virtual threads, threads stop being the limit at all, so those per-resource limits replace pool sizes. Every service publishes the same saturation metrics, limits are reviewed after major traffic or architecture changes rather than only after incidents, and dependencies with variable capacity get adaptive concurrency limits.
Why this question is asked
Concurrency settings chosen years ago tend to stay forever. Someone picked 200 threads and a pool of 50 connections, the numbers were copied into the next service, and nobody remembers why. The result is the mix the question describes: instances bigger than they need to be, and saturation incidents where a pool still turns out too small or a database too crowded. Interviewers ask this at a principal level because the answer is less about a formula than about a decision process that keeps working as traffic, architecture and the JVM itself change. In this answer, we will look at why guessed sizes fail, change what we limit, see what virtual threads change, define the metrics and review process, and decide where adaptive limits help.
1Why Guessed Pool Sizes Fail Both Ways
A thread pool size is a proxy. What we really care about is how much load we send to things that can saturate: a database's connections and CPU, a payment provider's connection limit, a downstream service's capacity. A guessed pool size relates to none of these directly. If it is too large, it lets more load through than the downstream can handle, and incidents follow. If it is too small, it throttles a service that could do more, so teams add instances, and the fleet is over-provisioned.
The other problem is time. A size that was right for 2,000 requests per second and a 20 ms database becomes wrong at 6,000 requests per second or after a schema change doubles query time, and nobody revisits it until something breaks.
2The Principle: Limit Resources, Not Threads
The first decision is to change the unit. For every downstream resource, we state its capacity, measured or agreed, and derive the limit each caller may use with Little's law: concurrency equals rate times latency. If a database can run 64 queries in parallel and has 8 services calling it, each with several instances, those 64 slots are divided among callers according to their traffic, with a reserve for deploys and operations.
That gives us a capacity model, a small table per resource saying who may use how much. Thread pools, connection pools and semaphores are then just the mechanisms that enforce the model's numbers, and when a number changes, we know exactly which settings follow.
Notice that the numbers come from the resource and from traffic, not from what a service happens to have. A new caller gets a share by negotiation, and if the shares no longer fit, that is a capacity decision for the database, made before an incident, not after.
3What Virtual Threads Change
Virtual threads, final since Java 21, make a blocked thread almost free. A service can run one virtual thread per request or per task, so the thread pool stops being a limit at all. That is good for waste: we no longer size instances around how many platform threads fit in memory, and services that were scaled out only to get more threads can shrink.
But there is a catch. The thread pool used to be a hidden limit on downstream load. When it disappears, nothing stops 20,000 virtual threads from calling a database built for 64 queries. So the move to virtual threads is exactly the moment to make the capacity model explicit: every resource gets a semaphore or a connection limit sized from the model, and the thread count becomes something we no longer configure. The fleet's capacity decisions become a list of resource limits, which is what they should have been all along.
| Concern | Before (guessed) | After (fleet standard) |
|---|---|---|
| Unit of capacity | threads per pool | concurrent use of each resource |
| Source of the number | copied from another service | Little's law on measured capacity |
| Enforcement | pool sizes | semaphores, connection limits, adaptive limiters |
| Threads | 200 platform threads | virtual threads, not a limit |
| Review | after incidents | after traffic or architecture changes, and yearly |
4Saturation Metrics for Every Service
A capacity model is only as good as its measurements. Every service publishes the same saturation metrics with the same names: for each limit, its size, how much is in use, how long callers wait for it, and how often it rejects. For connection pools that means active, idle and pending connections and acquire time; for executors, active threads and queue depth; for semaphores and adaptive limiters, permits in use and rejections. Each resource also publishes its own side: database CPU and active queries, a downstream's latency at its current load.
With these in place, a fleet-wide dashboard shows which limits run near 100 percent, which are always near 0, and how close each resource is to its capacity. The first list is the next incident; the second is over-provisioning we can remove.
5When to Revisit Limits
Instead of waiting for incidents, we define triggers that force a review of the capacity model for the affected resources: traffic growth of more than about 30 to 50 percent, a new caller of a shared resource, a change in a dependency's latency profile, a database migration or instance change, a move to virtual threads, and a yearly review of everything. A review is small: recompute the shares from current rate and latency, check the metrics, run a load test if the numbers moved a lot, and update the settings.
- Measure capacityload test: where throughput stops rising
- Measure demandpeak rate x latency per caller
- Demand fits under capacity minus reserve?YesAssign shares per caller and instanceNoAdd capacity or cut demand first
- Enforce with limitssemaphore, pool or adaptive limiter
- Watch saturation metricsusage, wait, rejections
- Trigger fired?traffic +30%, new caller, migrationYesReview againNoKeep current shares
6 steps in order. Play them, or step through them one at a time.
6Adaptive Limits for Variable Capacity
Some dependencies do not have a stable capacity. A shared search cluster is fast at night and slow during a reindex; a third-party API slows down without warning. A fixed limit is then either too high on bad days or too low on good days. An adaptive concurrency limit adjusts itself from what it observes: when latency stays near its normal level, it slowly raises the limit; when latency rises or errors appear, it cuts the limit quickly. This additive-increase, multiplicative-decrease idea is the same one TCP uses to find how much the network can carry. Netflix's concurrency-limits library is one open-source implementation; check what fits your stack.
Adaptive limits are not a replacement for the capacity model. They work inside a fixed ceiling from the model, so a bug in the algorithm can never exceed the agreed share. I would use them only for the dependencies whose capacity really varies, because fixed limits are easier to reason about and to explain during an incident.
7Follow-up questions
How would you roll this out across a large fleet?
Start with the shared resources that caused incidents, usually the main databases and one or two critical external dependencies, and build their capacity models first. The shared client library and starter enforce the limits, so services adopt them by upgrading. Over-provisioned services are right-sized as their metrics prove they have headroom, which pays for the work.
What if a team's demand exceeds its share of a resource?
Then it is an explicit capacity decision: increase the resource's capacity, reduce the team's latency or traffic, for example through caching, or move the work to a time or a replica with spare capacity. The important change is that the conflict is visible in the model before it shows up as an outage.
Do virtual threads make services faster?
Not by themselves. They make waiting cheap, which raises how many concurrent requests a service can hold, but each request still takes as long as its slowest dependency. The savings come from fewer, smaller instances and simpler configuration, as long as resource limits are in place.
8Conclusion
In this answer, we replaced guessed pool sizes with a fleet-wide way of making capacity decisions. Limits are set per resource from measured capacity and latency with Little's law and divided among callers in a capacity model; virtual threads remove threads as a limit, so explicit per-resource limits take over; every service publishes the same saturation metrics; limits are reviewed after traffic, caller or architecture changes and yearly, not only after incidents; and adaptive limits, inside fixed ceilings, handle dependencies whose capacity varies.
Open with
I would change what we decide. Thread pool sizes are a proxy; what actually saturates is downstream resources, databases, external providers, other services. So for every shared resource I would build a small capacity model: its measured capacity, a reserve for deploys and operations, and a share per caller and instance derived from Little's law, peak rate times latency.
Then, if they want more
Pools, connection limits and semaphores are then just how we enforce those numbers. Virtual threads make this the natural moment, because once threads are cheap the pool is no longer a limit at all, and without explicit per-resource limits a service could send thousands of concurrent calls to a database built for sixty.
So the standard is virtual threads for blocking work and explicit limits per resource, and the thread count stops being a setting.
Next, every service publishes the same saturation metrics, usage, wait time and rejections for each limit, so a fleet dashboard shows both the limits running hot, which are the next incidents, and the ones always idle, which are over-provisioning we can remove.
Then reviews: limits are revisited when traffic grows by thirty to fifty percent, a new caller arrives, a dependency's latency changes or an architecture change lands, plus a yearly pass, not only after incidents. Finally, for dependencies with variable capacity I would use adaptive concurrency limits that back off when latency rises, always inside the fixed ceiling from the model.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- Java 21
- 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
- java.util.concurrent, package documentation, JLS chapter 17, Threads and Locks
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 "Across your fleet, thread pool and connection pool sizes were chosen by guesswork years...": https://scrivio-interview-library.netlify.app/java/executors/792d4e307d/