Scrivio Interview library
DesignAdvanced7 min read · updated 12 November 2026

With virtual threads available, does your organisation still need non-blocking I/O frameworks such as Netty or WebFlux for new services? How would you decide per service?

For most new request-response services, no: with virtual threads, plain blocking code in Spring MVC scales to tens of thousands of concurrent requests, and it is far easier to write, debug and profile. Non-blocking frameworks still earn their place for streaming with back-pressure, very large numbers of mostly idle connections on little memory, and existing reactive systems that work well. We decide per service against a written default, after checking the libraries for pinning and heavy thread-local use.

Why this question is asked

For ten years the answer to "how do we handle lots of concurrent I/O in Java?" was Netty, Vert.x or Spring WebFlux, and teams paid for it with harder code. Virtual threads, final since Java 21, changed the economics, and many organisations now have to decide what their default is. Interviewers ask this at senior level because it tests judgement rather than API knowledge: knowing what each model actually buys, what migration costs, and how to turn that into a rule other teams can follow. In this answer, we will recap what each model costs, look at where virtual threads remove the old reason for reactive code, list the cases where non-blocking still wins, check the risks that block adoption, and finish with a per-service decision process and an organisation default.

1A Quick Recap of the Two Models

In thread-per-request, the model Spring MVC uses, each request gets a thread that runs our code top to bottom. When the code calls a database or another service, the thread blocks and waits. With platform threads, which are one-to-one with operating system threads, that waiting is expensive: Tomcat's default pool is 200 threads, so the 201st concurrent request queues even though the CPU is idle.

Non-blocking frameworks avoid that by never letting a thread wait. A few event-loop threads, one or two per core, run callbacks when I/O completes. Code is written as pipelines of Mono and Flux in Reactor, or futures in Netty. It scales very well, but a stack trace shows the framework, not our business logic, every library in the call chain must be non-blocking, and a single blocking call on an event loop stalls hundreds of requests.

Virtual threads are threads managed by the JVM rather than the operating system. When one blocks on I/O, the JVM unmounts it from its carrier thread and parks it on the heap, which costs a few kilobytes instead of a megabyte-sized stack reservation. So we can have one thread per request again, even with 50,000 concurrent requests, and keep the simple blocking style.

What each model costs
ConcernVirtual threads + MVCReactive (WebFlux, Netty)
Code styleplain sequential Javaoperator pipelines or callbacks
Stack traces and profilingshow our codemostly framework frames
Concurrency limitmemory and downstream poolsmemory and downstream pools
Back-pressure on streamsmanual (bounded queues)built in (request(n))
Idle connection costa parked thread, a few KBa channel and buffers, smaller still
Library requirementsordinary blocking librariesevery call must be non-blocking

2Where Virtual Threads Remove the Old Reason for Reactive Code

Most of our services are request-response: receive JSON, call a database and one or two other services, return JSON. For them, the only reason to go reactive was thread count. In Spring Boot 3.2 and later, one property moves request handling, @Async and scheduled tasks onto virtual threads.

Java
# application.properties (Spring Boot 3.2+ on Java 21+)
spring.threads.virtual.enabled=true
// controller code stays ordinary blocking code
@GetMapping("/orders/{id}")
OrderView order(@PathVariable long id) {
Order o = repo.findById(id).orElseThrow(); // blocks a virtual thread, not a carrier
Customer c = customers.fetch(o.customerId()); // RestClient call, also cheap to block
return OrderView.of(o, c);
}

But there is a catch: virtual threads remove the thread limit, not the downstream limits. If the connection pool has 50 connections, 5,000 concurrent requests still queue for those 50. We have to size pools and add timeouts deliberately, and sometimes add a Semaphore to protect a fragile dependency, because nothing in the thread model throttles us any more.

3Where Non-Blocking Still Wins

There are three cases where I would still pick a reactive or Netty-based stack. The first is streaming with back-pressure: a service that relays a fast Kafka topic to slow browser clients over server-sent events needs the producer to slow down when a consumer cannot keep up, and Reactor's request(n) protocol does that end to end, while with threads we would build bounded queues ourselves.

The second is very high connection counts with tiny per-connection work, such as a gateway or a chat service holding 500,000 mostly idle WebSockets. A parked virtual thread is cheap, but a channel with a small buffer on an event loop is cheaper still, and at that scale memory per connection decides the bill.

The third is existing reactive codebases that meet their goals. Rewriting a working WebFlux service costs weeks of engineering and new bugs, and gains nothing a user notices. Migration is justified when the reactive code is actively slowing the team down, for example frequent blocking-call incidents or nobody left who can debug it, not because it is no longer fashionable.

4Risks to Check Before Moving a Service

Virtual threads are only cheap when they can unmount. On Java 21, a virtual thread that blocks inside a synchronized block pins its carrier thread, so a library that holds a monitor around I/O could exhaust the small carrier pool. JDK 24 removed that limitation for synchronized (JEP 491), so on Java 25 the main remaining cause is blocking inside native code; check your version and the libraries' release notes. The JFR event jdk.VirtualThreadPinned shows where pinning happens.

The second risk is thread-local heavy code. Libraries that cache large objects per thread, such as buffer pools keyed by ThreadLocal, assumed 200 long-lived threads; with one short-lived virtual thread per request, the cache never hits and memory churns. Scoped values, final in Java 25, are the better tool for passing request context. We find these issues with a load test that compares throughput, p99 latency and allocation rate before and after the switch.

5Deciding Per Service, and Setting the Default

Asking every team to rediscover this produces a different answer per team. A senior engineer writes the default down, with the exceptions and the evidence each exception needs, so that choosing the non-default path is a short, reasoned design note rather than a matter of taste.

Step throughChoosing the I/O model for a service
  1. Existing reactive service that meets its goals?
    Yeskeep it; revisit only if it hurts deliveryNogo on
  2. Streams with back-pressure, or 100k+ idle connections?
    Yesreactive or Netty, with a design noteNogo on
  3. Libraries pin or rely heavily on ThreadLocal?
    Yesfix or replace them, then load testNogo on
  4. Default: Spring MVC on virtual threadssize pools and timeouts; measure p99 under load

4 steps in order. Play them, or step through them one at a time.

In practice our default would read: new HTTP services use Spring MVC with virtual threads on Java 25; reactive stacks are allowed for streaming, gateways and very high connection counts; existing reactive services stay unless a cost case says otherwise. With that default, a team building an ordinary CRUD service needs no meeting, and a team building an event gateway knows exactly what to justify.

6Follow-up questions

Do virtual threads make my code faster?

No. They do not make any single request faster; they let more requests wait at the same time without running out of threads. Throughput rises only when the bottleneck was the thread pool. If the database or CPU is the bottleneck, nothing changes, which is why we load test rather than assume.

Can I mix the two models, for example WebFlux calling blocking code?

Yes, but carefully. Blocking calls inside a reactive pipeline must be moved off the event loop, for example with subscribeOn(Schedulers.boundedElastic()). Mixing works for a few legacy calls; if most of the service blocks, the reactive layer adds complexity without benefit and MVC on virtual threads is the simpler home.

Should we pool virtual threads?

No. They are meant to be created per task and thrown away. Pooling them brings back the limit we just removed. To cap concurrency against a dependency, use a Semaphore or the dependency's own pool.

7Conclusion

In this answer, we saw that virtual threads make blocking cheap, so thread-per-request in Spring MVC once again scales for typical request-response services, with simpler code and better tooling. Non-blocking frameworks still win for streaming with back-pressure, enormous numbers of idle connections, and existing reactive systems that work. Before moving, we check libraries for pinning and thread-local habits and load test, and we capture the choice as an organisation default with documented exceptions.

What to say in the interviewAbout 90 seconds aloud

Open with

My starting point is that virtual threads took away the main reason most of our services went reactive, which was running out of threads. A typical service that takes a request, calls a database and a couple of APIs and returns JSON can run on Spring MVC with spring.threads.virtual.enabled and handle tens of thousands of concurrent requests with ordinary blocking code that is easy to read, debug and profile.

Then, if they want more

So for new services that would be my default. I would still choose WebFlux or Netty in specific cases: when the service streams data and needs real back-pressure, when it holds hundreds of thousands of mostly idle connections and memory per connection matters, or when it is an existing reactive service that works.

I would not rewrite those just to follow the trend. Before switching any service, I check for pinning, which on Java 21 meant synchronized blocks around I/O and on Java 25 is mostly native calls, and for libraries that cache heavily in ThreadLocals, then run a load test comparing p99 latency and memory.

I also remind teams that removing the thread limit exposes downstream limits, so connection pools and timeouts need to be sized on purpose. Finally I would write the default and its exceptions down, so each team makes the decision in a short design note instead of starting the debate again.

About this answer

Last updated
12 November 2026
Versions it names
Java 21, Java 25, Spring Boot 3.2, Java 24
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.
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 "With virtual threads available, does your organisation still need non-blocking I/O...": https://scrivio-interview-library.netlify.app/java/io-and-nio/e8f8db038c/