Scrivio Interview library
LeadershipPrincipal6 min read · updated 12 November 2026

Java web servers went from thread-per-request, to async servlets and reactive stacks, and now to virtual threads. What does this history mean for the programming model you would choose for new services today?

Async servlets and reactive stacks were mostly a way to avoid blocking scarce platform threads, and reactive code paid for that with code that is harder to write, debug and hire for. Virtual threads now let simple blocking code scale for most I/O-bound services, so for new services I would choose blocking code on virtual threads by default, keep reactive for streaming and backpressure-heavy workloads, and confirm the choice with a load test.

Why this question is asked

Every few years the recommended way to write a Java web service has changed, and many organisations now run all of these models at once. A senior engineer choosing the model for new services is really choosing what every future team member will have to read, debug and operate. Interviewers ask this question to see whether we understand the problem each step was solving, rather than following fashion. In this answer, we will walk through the history from thread-per-request to virtual threads, look at what reactive programming cost, compare the models, and then set out a default and the exceptions to it.

1The Problem Every Step Tried to Solve

In the original servlet model, each request held one platform thread from start to finish. Platform threads are operating system threads: each needs a stack (often around 1 MB) and context switching between thousands of them is costly, so servers used pools of a few hundred. As long as requests were short and CPU-bound, this was fine.

Then services started to spend most of their time waiting: on databases, on other services, on long-polling clients. A request that waits 500 ms for a downstream call keeps its thread idle for 500 ms. With 200 threads, a service could handle at most 400 such requests per second no matter how idle its CPU was. Every later model is an answer to the same question: how do we wait without wasting a thread?

2Async Servlets and Reactive Stacks

Servlet 3.0 added async processing: a request could be parked with startAsync() and finished later by another thread, and Spring MVC exposed this as Callable and DeferredResult. It helped for long polls and slow calls, but the code inside still blocked somewhere unless every library was non-blocking.

Reactive stacks went all the way. Spring WebFlux on Netty, with Project Reactor's Mono and Flux types, uses a small number of event-loop threads and never blocks them. Each step of a request is a callback in a chain. A service can hold tens of thousands of concurrent connections with a handful of threads, and Reactor adds backpressure, a way for a slow consumer to tell a fast producer to slow down.

3What Reactive Programming Cost

The price was paid in everyday work. Code becomes a chain of operators instead of a sequence of statements, so a simple if, loop or try-catch turns into flatMap, switchIfEmpty and onErrorResume. Stack traces show Reactor internals rather than our method calls. ThreadLocal-based features such as logging context and security context need special handling. A single accidental blocking call on an event loop can stall many requests. And every library on the path must be reactive, which ruled out JDBC until R2DBC arrived.

Java
// Reactive: fetch a user, then their orders, fall back if none
Mono<Summary> summary(long id) {
return users.findById(id)
.switchIfEmpty(Mono.error(new NotFound(id)))
.flatMap(u -> orders.findByUser(u.id()).collectList()
.map(list -> new Summary(u, list)));
}
// Blocking on a virtual thread: the same logic
Summary summary(long id) {
User u = users.findById(id).orElseThrow(() -> new NotFound(id));
return new Summary(u, orders.findByUser(u.id()));
}

Both versions scale for I/O-bound work on modern Java, but the second one can be read, debugged and reviewed by any Java developer. That is why, in many organisations, reactive adoption stayed limited to a few teams with a strong need and the skills to support it; hiring for it was hard, and ordinary CRUD services gained little.

4What Virtual Threads Change

Virtual threads, final in Java 21, attack the original problem directly. The JVM schedules many cheap virtual threads on a few carrier threads, and when a virtual thread blocks on I/O it is unmounted so the carrier can run another one. Waiting no longer wastes an operating system thread, so the plain blocking model scales to thousands of concurrent requests. Spring Boot 3.2 and later enables this with spring.threads.virtual.enabled=true. Java 24 removed the main pinning problem with synchronized blocks, so on Java 25 LTS it works with most existing libraries.

In effect, the JVM now does the work that reactive code asked us to do by hand. The code stays sequential, stack traces stay readable, and JDBC, ThreadLocal and debuggers all work as before.

Programming models compared
ModelWaiting costsCode styleBest fit today
Thread per request (platform)One OS thread per waiting requestSimple blockingLow-concurrency internal apps
Async servletsThread freed while parkedCallbacks at edgesExisting long-poll code
Reactive (WebFlux)Almost nothingOperator chainsStreaming, backpressure, gateways
Virtual threadsAlmost nothingSimple blockingDefault for I/O-bound services

5Where Reactive Still Earns Its Place

Virtual threads solve concurrency, not flow control. Reactive streams still offer things virtual threads do not: backpressure built into the type system, natural composition of streams of events, and efficient handling of very many long-lived connections such as server-sent events, WebSockets or a gateway proxying streams. An API gateway, a service that fans out a market data feed to thousands of clients, or a pipeline where producers must slow down for consumers is still a good reactive candidate. A team that already runs WebFlux well should not rewrite it just because virtual threads exist.

6The Default I Would Set, and Why

For new services, I would make Spring MVC with blocking code on virtual threads the default, on Java 25. It gives most of the scalability that reactive was adopted for, with code that any Java developer can maintain. Teams can choose reactive when they can name the feature they need, such as backpressure or streaming to many clients. And in both cases we load test with a realistic workload, because virtual threads move the bottleneck to connection pools and downstream services, and a default is only a starting point. The lesson from the history is that the model should follow the constraint we actually have.

7Follow-up questions

Are virtual threads always faster than reactive?

No. They are not about raw speed. For CPU-bound work neither model helps much. For I/O-bound work both scale well; reactive may use slightly less memory per connection, while virtual threads are simpler. The deciding factor for most services is maintainability, not a few percent of throughput.

Would you migrate existing WebFlux services to virtual threads?

Only with a reason, such as a team that struggles to maintain reactive code or frequent bugs from blocking calls on event loops. A working reactive service that the team understands is not a problem to solve. New services can follow the new default while old ones stay as they are.

What about structured concurrency?

Structured concurrency, previewed in recent JDKs, gives blocking code a clean way to run several subtasks in parallel and cancel them together, which covers one of the composition benefits of reactive. Check your JDK version for its status; until it is final, CompletableFuture or a simple executor of virtual threads works for fan-out.

8Conclusion

In this answer, we saw that async servlets and reactive stacks were answers to one constraint: platform threads were too expensive to block. Reactive solved it at a real cost in readability, debugging and hiring, which limited its use for ordinary services. Virtual threads remove the constraint inside the JVM, so blocking code on virtual threads is a sensible default for new I/O-bound services, with reactive kept for streaming and backpressure, and load tests to confirm each choice.

What to say in the interviewAbout 80 seconds aloud

Open with

I read the history as one problem solved several ways. Thread-per-request on platform threads was simple, but a waiting request held an expensive OS thread, and once services spent most of their time waiting on I/O, a pool of 200 threads became the limit.

Then, if they want more

Async servlets let us park requests, and reactive stacks like WebFlux removed blocking completely, but reactive paid for it: code turns into operator chains, stack traces are hard to read, ThreadLocal context needs special handling, every library must be non-blocking, and it is harder to hire for. So outside a few teams it never became the norm.

Virtual threads fix the original constraint inside the JVM: blocking is cheap, so plain sequential code scales for I/O-bound work. For new services today I would default to Spring MVC with blocking code on virtual threads on Java 25.

I would still pick reactive when a team can name a reactive feature they need, like backpressure, streaming to many long-lived connections, or a gateway. I would not rewrite working WebFlux services without a reason. And whatever the choice, I would load test, because the bottleneck moves to connection pools and downstream services.

About this answer

Last updated
12 November 2026
Versions it names
Java 25, Java 21, Java 24, 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 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
Jakarta EE specifications
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 "Java web servers went from thread-per-request, to async servlets and reactive stacks...": https://scrivio-interview-library.netlify.app/java/servlets/6deb1a76d0/