Scrivio Interview library
ConceptFoundations6 min read · updated 12 November 2026

What are the main differences between Spring MVC and Spring WebFlux in threading model, supported servers and programming model?

Spring MVC is built on the Servlet API and gives each request its own thread, which blocks while it waits for I/O. Spring WebFlux is built on Reactive Streams and handles many requests on a few event-loop threads that must never block. WebFlux runs on Netty by default in Spring Boot and can also run on Servlet containers through their non-blocking I/O, both stacks support annotated controllers and functional endpoints, and an application should pick one: with both starters present, Boot configures MVC.

Why this question is asked

Choosing between Spring MVC and WebFlux is one of the first decisions for any new Spring web service, and it affects every line of code that follows: method signatures, database access, testing, debugging and what is safe to call. Interviewers ask about the differences to check that we understand the threading model underneath, not just the return types. In this answer, we will compare the threading models with a concrete example, look at the servers each stack runs on, see why blocking an event loop is so damaging, compare the programming models, and finish with what happens when both starters end up on the classpath.

1A Quick Recap of the Two Stacks

Spring MVC has been Spring's web framework since the beginning. It sits on the Servlet API, the Jakarta standard for Java web servers, and its central class, DispatcherServlet, routes each request to a controller method. Spring WebFlux was added in Spring Framework 5 as a parallel stack. Its central class, DispatcherHandler, plays the same role, but it sits on Reactive Streams, the standard for asynchronous streams with backpressure, using Project Reactor's Mono and Flux types.

The two stacks share a lot of concepts and annotations, which is why they look alike in code. The difference is in how threads are used while a request is in progress.

2Thread per Request Versus an Event Loop

In MVC, the server takes a thread from its pool, Tomcat's default is 200, and that thread runs the request from start to finish. When the controller queries the database, the thread blocks until the rows arrive. So the number of requests in progress at once is limited by the number of threads. That model is simple to write, read and debug, and with virtual threads, available since Java 21 and enabled in Spring Boot with spring.threads.virtual.enabled=true, the limit of threads largely disappears because blocked virtual threads are cheap.

In WebFlux on Netty, a small number of event-loop threads, by default about one per CPU core, handle all connections. When a handler calls a non-blocking client, it registers what to do with the result and returns immediately; the event loop moves on to other connections, and the result is processed when it arrives. So a few threads can serve thousands of concurrent requests, as long as no one blocks them.

Java
// MVC: the thread waits for the database, then returns the value
@GetMapping("/orders/{id}")
Order order(@PathVariable long id) { return repository.findById(id).orElseThrow(); }
// WebFlux: returns at once with a Mono; the event loop is free until the row arrives
@GetMapping("/orders/{id}")
Mono<Order> order(@PathVariable long id) { return reactiveRepository.findById(id); }
Spring MVC compared with Spring WebFlux
AspectSpring MVCSpring WebFlux
FoundationServlet API, blocking I/OReactive Streams, non-blocking I/O
Threadsone per request (pool or virtual)few event loops shared by all requests
Default server in BootTomcatReactor Netty
Other serversJettyTomcat, Jetty via Servlet non-blocking I/O
Return typesplain values, ResponseEntityMono, Flux, or plain values
Data accessJDBC, JPAR2DBC, reactive clients
Programming modelsannotated, functional (WebMvc.fn)annotated, functional (WebFlux.fn)

Notice that the WebFlux version only pays off if reactiveRepository is truly non-blocking, for example built on R2DBC. Return types alone do not make code non-blocking.

3Supported Servers

WebFlux does not need the Servlet API, so Spring Boot's spring-boot-starter-webflux uses Reactor Netty by default. It can also run on Servlet containers such as Tomcat and Jetty, through a bridge that uses the Servlet API's non-blocking I/O features rather than its blocking ones. MVC requires a Servlet container, with Tomcat as Boot's default and Jetty as an alternative. Undertow was a third option for years, but recent Boot versions have dropped it, so check your version before choosing it.

4Why Blocking an Event Loop Hurts So Much

In MVC, one slow call blocks one thread, and one request waits. In WebFlux, every connection is assigned to one event loop, so a blocking call on that loop freezes every request on it. On an 8-core machine there might be 8 loops handling 2,000 connections; one JDBC call taking 100 ms on a loop delays roughly 250 connections by 100 ms. That is why WebFlux code must use non-blocking drivers throughout, and why any unavoidable blocking call is moved to Schedulers.boundedElastic().

Step throughOne blocking call on a shared event loop
Connection 1Connection 2Event loop 3Database (JDBC)
request A
blocking query for A
request B arrives
still waiting for A: B is not read
rows for A after 100 ms
response A
only now handles B

7 messages in order. Play them, or step through them one at a time.

Every connection on the same loop waits for the blocking call.

5Programming Models, and Choosing One Stack

Both stacks support two programming models. Annotated controllers use @RestController, @GetMapping and friends, and look almost the same in both. Functional endpoints declare routes as code with RouterFunction and handler functions; WebFlux has WebFlux.fn and MVC has WebMvc.fn, with very similar APIs.

An application should use one stack. If both spring-boot-starter-web and spring-boot-starter-webflux are on the classpath, Spring Boot configures Spring MVC, not WebFlux. This is deliberate: many MVC applications add the webflux starter only to use WebClient, and Boot keeps them on MVC. If we really wanted WebFlux in that situation, we could force it with spring.main.web-application-type=reactive, but the cleaner fix is to remove the starter we do not need.

6Follow-up questions

Can I use WebClient in a Spring MVC application?

Yes, and it is common. Adding spring-boot-starter-webflux for WebClient leaves the app on MVC. In an MVC controller we can call block() on the result, which is fine on a Servlet thread, or return the Mono directly, since MVC supports reactive return types by adapting them to async request processing. Spring Framework 6.1 also added RestClient, a synchronous client with a fluent API, which is often simpler for MVC.

Is WebFlux faster than MVC?

Not per request. A single request is usually no faster, and the reactive machinery adds some overhead. WebFlux handles more concurrent requests with fewer threads when the I/O is non-blocking, which matters for streaming, long-lived connections and high fan-out. With virtual threads, MVC closes much of that gap for typical services.

Do Spring Security and validation work the same in both?

Both stacks have them, but they are separate implementations. WebFlux uses SecurityWebFilterChain and ReactiveSecurityContextHolder, with the security context carried in Reactor's context instead of a ThreadLocal, and MVC uses SecurityFilterChain and SecurityContextHolder. Validation with @Valid works on annotated controllers in both.

7Conclusion

In this answer, we saw that Spring MVC sits on the Servlet API with a thread per request that blocks during I/O, while WebFlux sits on Reactive Streams and serves many requests on a few event-loop threads. WebFlux runs on Netty by default in Boot and also on Servlet containers through non-blocking I/O, a blocking call on its event loop stalls every connection on that loop, both stacks offer annotated and functional endpoints, and with both starters on the classpath Boot chooses MVC.

What to say in the interviewAbout 90 seconds aloud

Open with

The core difference is the threading model. Spring MVC is built on the Servlet API with a thread per request: Tomcat gives the request a thread, and that thread blocks while it waits for the database or another service.

Then, if they want more

It's simple to write and debug, and with virtual threads on Java 21 and later, blocked threads are cheap, so the concurrency limit mostly disappears. WebFlux is built on Reactive Streams with Reactor's Mono and Flux.

It runs on a small number of event-loop threads, about one per core, and a handler never waits: it returns a Mono, and the result is processed when the I/O completes.

That lets a few threads handle thousands of concurrent requests, but only if everything is non-blocking, so R2DBC instead of JDBC and WebClient instead of a blocking client, because a blocking call on an event loop stalls every connection on that loop.

On servers, Boot runs WebFlux on Reactor Netty by default, and it can also run on Tomcat or Jetty using Servlet non-blocking I/O, while MVC needs a Servlet container. On programming models, both support annotated controllers and functional endpoints, WebMvc.fn and WebFlux.fn.

And an application should use one stack: if both the web and webflux starters are present, Boot configures MVC, which is deliberate so MVC apps can add webflux just to use WebClient.

About this answer

Last updated
12 November 2026
Versions it names
Java 21, Spring Framework 5, Spring Framework 6
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 "What are the main differences between Spring MVC and Spring WebFlux in threading model...": https://scrivio-interview-library.netlify.app/spring-boot/webflux/7ad1655158/