Quick revision
The short answer
Not as a blanket default on day one. The benefits are largest for I/O-bound services with many blocking calls, and the risks are downstream overload, pinning with older JDKs and libraries, and changed ThreadLocal behaviour. I would first add concurrency limits to the platform starter, then roll out by service class with load tests and before-and-after metrics, keep a property-based switch for fast rollback, and make virtual threads the default only once the evidence supports it.
What to remember
In this answer, we decided not to switch virtual threads on everywhere at once. The gains are largest for I/O-bound services with many blocking calls, while the risks are downstream overload, pinning with older JDKs and libraries, and changed ThreadLocal behaviour. We prepared the platform starter with concurrency limits and metrics first, rolled out by service class with load tests and before-and-after comparisons, kept a property-based switch for fast rollback, and made it the default only once our own evidence supported it.
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.
Not as a blanket default on day one. The benefits are largest for I/O-bound services with many blocking calls, and the risks are downstream overload, pinning with older JDKs and libraries, and changed ThreadLocal behaviour. I would first add concurrency limits to the platform starter, then roll out by service class with load tests and before-and-after metrics, keep a property-based switch for fast rollback, and make virtual threads the default only once the evidence supports it.
Why this question is asked
A platform team can change hundreds of services with one line in a shared starter, which is both its power and its danger. Virtual threads look like an obvious win, and for many services they are, but a change that removes a hidden concurrency limit everywhere at once can overload every shared database in the same week. Interviewers ask this to see how we manage a broad, attractive change with real risks. In this answer, we will weigh who benefits and what can go wrong, prepare the platform before switching anything, roll out by service class with measurement, and keep the rollback one property away.
1A Quick Recap of What Changes
With spring.threads.virtual.enabled=true on Java 21 or later, Tomcat and Jetty handle each request on its own virtual thread, and the auto-configured executor and scheduler use virtual threads too. Blocking calls no longer hold a scarce platform thread, so a service can have thousands of requests waiting on I/O at once. At the same time, the fixed pool of 200 threads, which quietly limited how many requests reached each downstream, is gone.
2Where the Benefits Are Largest
The gain depends on what the threads spend their time doing. A service that spends 90 percent of each request waiting on HTTP calls and the database, such as an aggregation API calling four other services, can handle many times more concurrent requests on the same hardware. A service that mostly computes, such as image processing or a rules engine, gains nothing, because virtual threads still need a carrier to compute. A service that already runs at low concurrency, say 20 requests at once, never ran out of threads in the first place.
So the first step of the plan is to sort services into classes by measured behaviour: thread pool saturation, time spent blocked, and peak concurrency. That tells us where the change pays and where it is noise.
| Class | Example | Expected gain |
|---|---|---|
| I/O-heavy, high concurrency | Aggregation API, many calls | Large: more requests, same nodes |
| I/O, moderate concurrency | Typical CRUD service | Small, mainly headroom at peaks |
| CPU-bound | Pricing engine, image work | None |
| Old JDK or pinning-prone libraries | Java 17, old drivers | Not eligible until upgraded |
3The Risks to Plan For
Downstream overload is the biggest risk. Removing the thread pool sends the full concurrency to databases, caches and partner APIs. If a hundred services do it in the same month, a shared database can see several times its usual connection attempts.
Pinning is the second. On JDKs before 24, a virtual thread blocking inside synchronized code holds its carrier thread, and libraries that synchronize around I/O, such as some older JDBC drivers and clients, can stall a service under load. The third is changed ThreadLocal behaviour: with no thread reuse, per-thread caches are rebuilt for every request, which costs memory, and code that relied on a ThreadLocal value lingering between requests, usually a bug anyway, behaves differently. Each risk has a specific check, which is why we roll out with measurement rather than hope.
4Preparing the Platform Before Switching
Before any service enables virtual threads, the platform starter gets the protections that the thread pool used to provide by accident. Shared HTTP clients get a configurable concurrency limit per downstream, connection pools get sizes from database capacity and short timeouts, and dashboards gain the metrics we need to judge the change: downstream concurrency, pool waits, pinning events from JFR and heap use.
The property-based switch is the key to a calm rollout. Because the value comes from an environment variable with a default, a service can turn virtual threads on or off per environment without a code change or a new build. If a problem appears in production at peak, the on-call engineer flips it back and restarts.
5Rolling Out by Service Class
We start with the class that benefits most, the I/O-heavy services, and with one or two volunteer teams. Each service runs the same load test with the switch off and on, and we compare latency, throughput, error rate, downstream concurrency, heap use and pinning events. Then the service runs in staging, then in production for a share of instances, and only then fully.
After each class, we write down what we learned, for example a driver version that pinned or a cache that grew, and fix it in the starter so the next class benefits. CPU-bound services can skip the change entirely, and services on older JDKs upgrade first.
- Platform starter adds limits and metrics
- Load test with the switch off, then on
- Downstreams, heap and pinning within limits?YesEnable in staging, then some production podsNoFix limits or libraries, test again
- Production metrics stable for a week?YesEnable for all podsNoFlip the switch back
- Record lessons in the starter
5 steps in order. Play them, or step through them one at a time.
6Deciding When It Becomes the Default
Once the I/O-heavy and typical classes have run on virtual threads for a few months without incidents, with JDK 24 or later across the estate to remove most pinning, I would make the switch default to on for new services and then for existing ones, still overridable per service. At that point the default reflects evidence from our own systems rather than a conference talk, and the protections in the starter mean the change no longer depends on each team noticing its hidden limits.
7Follow-up questions
Why not enable it everywhere and roll back the services that fail?
Because the failures may not appear in the service that changed. A shared database overloaded by twenty services at once fails for everyone, including services that never enabled anything, and finding the cause across many simultaneous changes is slow. A staged rollout keeps each change observable.
Which metrics show that a service is ready?
Thread pool saturation or long request queues before the change, plus a high share of time blocked on I/O, show where it helps. After the change, stable downstream concurrency, no growth in pool wait time, no pinning events and steady heap use show it is safe.
Does Java 25 change the plan?
It reduces one risk. JDK 24 removed most pinning in synchronized code, and Java 25 is the current long-term support release, so an estate on Java 25 has fewer library surprises. Downstream overload and ThreadLocal costs are unchanged, so the limits and the load tests stay in the plan.
8Conclusion
In this answer, we decided not to switch virtual threads on everywhere at once. The gains are largest for I/O-bound services with many blocking calls, while the risks are downstream overload, pinning with older JDKs and libraries, and changed ThreadLocal behaviour. We prepared the platform starter with concurrency limits and metrics first, rolled out by service class with load tests and before-and-after comparisons, kept a property-based switch for fast rollback, and made it the default only once our own evidence supported it.
Open with
I would not enable it for everyone on day one, but I would plan for it to become the default. The benefit is real but uneven: it is largest for I/O-bound services that make many blocking calls at high concurrency, and close to zero for CPU-bound services or services that never ran out of threads.
Then, if they want more
The risks are specific. Removing the 200-thread pool removes an accidental limit, so downstreams like shared databases and partner APIs can be overloaded. On JDKs before 24 and with some older libraries, synchronized code can pin virtual threads. And ThreadLocal caches are rebuilt per request, which costs memory.
So first I would add protections to the platform starter: concurrency limits per downstream client, pools sized from database capacity with short timeouts, and dashboards for downstream concurrency, pool waits, pinning and heap.
Then I would roll out by service class, starting with the I/O-heavy ones, each with a load test with the switch off and on and a comparison of the metrics, then staging, then part of production. The switch is a property fed from an environment variable, so rolling back is a config change and a restart.
Once the evidence is good and the estate is on a recent JDK, I would make it the default, still overridable per service.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- Java 24, Java 25, 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
- Spring Boot reference
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 "Would you enable virtual threads by default for all MVC services in your organisation?...": https://scrivio-interview-library.netlify.app/spring-boot/embedded-servers/ae35612d32/