Quick revision
The short answer
The history teaches that a concurrency model is a trade-off tied to its time, not a permanent truth. Reactive stacks solved thread scarcity but cost a great deal in code complexity, debugging and hiring; virtual threads now remove most of that scarcity for ordinary blocking code, while reactive still fits streaming and back-pressure. So for long-lived systems we choose the model our teams can operate and debug, and we keep business logic independent of it so the next shift is cheap.
What to remember
In this answer, we saw that each Java concurrency model solved the problem of its time. Reactive stacks solved thread scarcity at a high cost in complexity, debugging and hiring; virtual threads remove much of that scarcity for blocking code, which changes the trade-off, while reactive still fits streaming and back-pressure. For long-lived systems, we choose the model our teams can operate and debug, match it to the workload, and keep business logic independent of 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.
The history teaches that a concurrency model is a trade-off tied to its time, not a permanent truth. Reactive stacks solved thread scarcity but cost a great deal in code complexity, debugging and hiring; virtual threads now remove most of that scarcity for ordinary blocking code, while reactive still fits streaming and back-pressure. So for long-lived systems we choose the model our teams can operate and debug, and we keep business logic independent of it so the next shift is cheap.
Why this question is asked
Systems built today will probably outlive the concurrency model they are written in. Java has already moved from one thread per request, to event loops and reactive libraries, and back to blocking code on virtual threads, all within about fifteen years. Interviewers ask this at principal level to see whether we can learn from that movement instead of chasing it. In this answer, we will recap the three models and the problem each solved, look at what each one cost, and then turn the history into rules for choosing a model for a system that must live for a decade.
1A Quick Recap of the Three Models
In the thread-per-request model, each incoming request gets an operating system thread for its whole life. The code is plain and blocking: call the database, wait, call another service, wait. It is easy to read and easy to debug, because a stack trace shows the whole story of a request. Its limit is that platform threads are expensive, about a megabyte of stack reserved each and costly to switch, so a server could only afford a few hundred of them.
Event loops and reactive stacks, such as Netty, Project Reactor and Spring WebFlux, solved that limit by never blocking. A handful of threads serve thousands of connections; when code waits for I/O, it registers a callback and the thread moves on. Reactive libraries added back-pressure, a way for a slow consumer to tell a fast producer to slow down.
Virtual threads, final in Java 21, take a third path. They are threads managed by the JVM rather than the OS, so we can have millions of them. When a virtual thread blocks on I/O, the JVM parks it and frees the carrier platform thread underneath. Plain blocking code then scales almost like event-loop code.
| Model | Solved | Cost |
|---|---|---|
| Thread per request | Simple, readable, debuggable code | Few hundred threads; waiting threads are scarce |
| Event loop and reactive | Thousands of connections on few threads | Operator chains, poor stack traces, rare skills |
| Virtual threads | Blocking code with huge concurrency | Downstream overload, pinning on older JDKs |
2What Reactive Really Cost
Reactive code solved a real problem in 2015, when a service making three slow downstream calls would run out of threads long before it ran out of CPU. But the price was paid every day by every developer. Logic that used to be a sequence of statements became a chain of flatMap, switchIfEmpty and onErrorResume operators. A stack trace from inside a reactive chain shows the library's scheduling code rather than our business steps, so a simple null pointer could take an hour to trace. ThreadLocal-based tools such as MDC logging and security contexts needed special context propagation.
Hiring and onboarding paid too. A team needs people who can write and review reactive code safely, because one accidental blocking call on an event loop can stall the whole server. Those people are rarer and take longer to train. So the throughput gain was real, but it came with a permanent tax on change.
3How Virtual Threads Changed the Trade-off
The reason reactive was worth its cost was thread scarcity. Virtual threads remove most of that scarcity for blocking code, so the main argument for reactive in ordinary request-response services is much weaker. A Spring MVC service with spring.threads.virtual.enabled=true can hold thousands of concurrent requests that wait on I/O, while the code stays as readable as the second version above.
But notice what did not change. Downstream limits still apply: a database with a pool of 20 connections still serves 20 queries at a time. And reactive still fits some problems better than anything else. Streaming large or endless data, server-sent events to many clients, and pipelines where a slow consumer must push back on a fast producer are exactly what back-pressure was designed for. So the honest conclusion is not that reactive was a mistake, but that its sweet spot is narrower than it once was.
4Rules for Choosing a Model for a Long-Lived System
The first rule I take from the history is to choose the model our teams can operate and debug. A system lives for ten years and is changed by people who did not write it. Every hour lost reading an operator chain or chasing a lost MDC context is paid again on every change. Complexity has a long-term cost that a throughput benchmark does not show.
The second rule is to match the model to the workload, not to fashion. For request-response services that mostly wait on I/O, blocking code on virtual threads is now the default choice. For streaming and back-pressure, reactive earns its cost. For CPU-heavy work, neither helps; we need enough cores and a bounded pool.
The third rule is to keep business logic independent of the concurrency model where possible. If the domain code is plain methods that take values and return values, and only the edges such as controllers and clients know about Mono or virtual threads, then moving between models means rewriting adapters, not the business rules.
- Streaming or back-pressure at the core?YesReactive (WebFlux) for that partNoGo on
- Mostly waiting on I/O?YesBlocking code on virtual threadsNoGo on
- CPU-bound workbounded platform-thread pool sized to cores
- Keep domain logic free of the modeladapters at the edges
4 steps in order. Play them, or step through them one at a time.
5An Example Decision
Suppose we own 60 WebFlux services written in 2019 and a team proposes rewriting them all in blocking style. I would not approve a big rewrite just because the fashion changed. Instead I would write new request-response services in blocking style on virtual threads, migrate an existing reactive service only when it needs substantial change anyway, and keep the reactive services that genuinely stream data. Over three years the estate shifts toward the simpler model without a risky big-bang project, and each move is justified by work we were going to do anyway.
6Follow-up questions
Does this mean we should never start a new reactive service?
No. If the service streams data, holds many long-lived connections such as server-sent events, or needs back-pressure between producer and consumer, reactive is still a strong fit. The point is to choose it for those properties, not for thread scarcity that virtual threads already solve.
How do you keep business logic independent of the concurrency model?
Put domain rules in plain classes that take inputs and return results without Mono, Flux or thread handling. Controllers, repositories and clients adapt them to the chosen model. Then a switch from reactive to blocking, or the reverse, changes the edges and leaves the rules and their tests untouched.
What should we watch when moving reactive code to virtual threads?
Concurrency that was limited by the event loop or explicit operators becomes unlimited, so downstream services and pools can be overloaded. Add explicit concurrency limits, check libraries for pinning on JDKs before 24, and load test before and after.
7Conclusion
In this answer, we saw that each Java concurrency model solved the problem of its time. Reactive stacks solved thread scarcity at a high cost in complexity, debugging and hiring; virtual threads remove much of that scarcity for blocking code, which changes the trade-off, while reactive still fits streaming and back-pressure. For long-lived systems, we choose the model our teams can operate and debug, match it to the workload, and keep business logic independent of it.
Open with
What the history teaches me is that a concurrency model is a trade-off for its time. Thread per request was simple, but platform threads were scarce, so a few hundred slow calls could exhaust a server.
Then, if they want more
Reactive stacks solved that by never blocking, but the cost was high and permanent: operator chains instead of plain code, stack traces that show the scheduler rather than our logic, special handling for things like MDC, and fewer engineers who can write it safely.
Virtual threads remove most of the thread scarcity for blocking code, so for ordinary request-response services the main argument for reactive is much weaker. Reactive still fits streaming, many long-lived connections and back-pressure, where it really earns its cost.
So for a long-lived system, I choose the model my teams can operate and debug at three in the morning, because complexity is paid on every change for ten years. Today that is usually blocking code on virtual threads, with explicit limits for downstreams.
And I keep business logic independent of the model, in plain classes, with Mono or thread handling only at the edges. Then the next shift, and there will be one, changes adapters, not the business rules, and we can migrate gradually instead of rewriting.
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
- 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 "Java servers moved from thread-per-request to event loops and reactive stacks, and now...": https://scrivio-interview-library.netlify.app/spring-boot/embedded-servers/d509673a1b/