October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk5 min

How Threading Works in Spring WebFlux

Spring WebFlux uses event-loop workers rather than a thread per request, but schedulers, servers, connectors, and blocking dependencies shape the actual thread model.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Spring WebFlux does not normally create a thread for every request. With a supported non-blocking server, it handles requests using a comparatively small event-loop worker pool and expects application work not to block those workers. Reactive operators do not each start a thread; execution changes pools only when a scheduler or another component arranges it. That model can use resources efficiently for latency-heavy I/O, but it does not automatically make code run faster.

What is the WebFlux threading model?

Spring MVC is designed around the possibility that request-handling code will block—for example, while waiting for a remote service. Servlet containers commonly use larger pools so other request threads can continue while one is waiting. WebFlux instead assumes application code is non-blocking. A server can use a small, fixed-size event-loop worker pool to handle requests and resume work as I/O completes, rather than reserving a blocked thread for each operation. Spring Framework’s WebFlux overview describes this contrast.

This is not a promise that the server has one thread, nor that every request gets a new one. Spring’s illustrative vanilla WebFlux server has one server thread and several request-processing threads, typically as many as the CPU cores. That is a documentation example, not a universal thread count or a performance measurement. Servlet-container integrations may also have threads associated with their blocking and non-blocking APIs.

WebFlux supports multiple server integrations, including Netty and servlet containers such as Tomcat and Jetty. The concrete arrangement therefore depends on the server and its configuration. Spring Boot’s WebFlux starter defaults to Netty; that statement is specific to the starter and should be checked against the Spring Boot version in use.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Which thread runs a controller or reactive pipeline?

There is no single answer for every application. The server, client connector, scheduler transitions, and libraries that create their own threads all affect where work runs. With a typical non-blocking server, request handling is associated with event-loop workers. A controller returning a reactive type participates in a reactive pipeline, but the pipeline does not imply a fresh thread at each stage.

Reactor operators describe stages in a sequence. Scheduler abstractions provide a way to run work using a selected thread-pool strategy when a transition is needed. Spring’s overview gives parallel as an example for CPU-bound work and elastic for I/O-bound work. These names and recommended choices depend on the Reactor version; consult that version’s documentation before using a scheduler in code.

Spring describes work within a reactive pipeline as proceeding sequentially through its distinct stages, which can help avoid concurrent invocation of mutable state within that pipeline. This is not a guarantee that application state is globally thread-safe: requests can overlap, libraries and callbacks can introduce concurrency, and an explicit scheduler transition changes execution context.

How do WebClient and server event loops relate?

When WebClient uses Reactor Netty, Spring describes the client as operating in an event-loop style. If a Reactor Netty client and server are both in use, they share event-loop resources by default, according to the WebFlux overview. The ReactorResourceFactory reference describes Reactor Netty global resources as including event-loop threads and a connection pool. That reference is on a 7.0-SNAPSHOT path, so verify resource-lifecycle details against the stable Spring version you deploy, particularly if your application starts and stops contexts in-process.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Third-party data-access and other libraries may create their own threads, so a WebFlux application is not necessarily limited to the server’s event-loop pool. Thread names such as reactor-http-nio- or scheduler-related names can help identify an active pool, but a thread name by itself cannot establish that a handler is isolated correctly or that the application is non-blocking.

What should you do with blocking calls?

A blocking call holds the thread until it finishes. If that thread is an event-loop worker, it cannot promptly process other events assigned to it. Spring therefore treats blocking APIs as a poor fit for this model. The preferred approach is to use non-blocking dependencies and keep the request path non-blocking. If blocking work is unavoidable, isolate it on an explicitly chosen executor or scheduler with capacity suitable for the dependency; wrapping the call in a reactive operator does not make the call itself non-blocking.

Keep controller responses reactive

When composing WebClient calls in a Spring MVC or WebFlux controller, Spring advises against calling block() to wait for a Mono or Flux. Return the reactive type instead. For Kotlin, the guidance is to use suspending functions or return Flow. This controller advice does not prohibit intentionally bridging to synchronous code at a boundary, but such a bridge should be explicit rather than hidden in the request path. See Spring’s synchronous WebClient documentation.

Configure blocking controller execution when needed

Spring’s WebFlux configuration reference describes a controller mechanism for applications that must execute blocking controller methods separately: a WebFluxConfigurer can provide an AsyncTaskExecutor. By default, methods whose return types are not recognized by the configured ReactiveAdapterRegistry are considered blocking for this mechanism; a custom predicate can change that determination. Confirm the behavior and configuration against the Spring Framework version and application setup in use. The WebFlux configuration reference documents the mechanism.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

When does WebFlux make sense compared with MVC?

Consideration WebFlux Spring MVC
Blocking dependencies Best suited to non-blocking persistence and network APIs. Blocking APIs can be isolated, but are not a natural fit. Its request-handling model accommodates blocking code and dependencies.
Latency and concurrency Can be advantageous when many operations wait on slow or unpredictable I/O and the application can use non-blocking operations. A larger pool can absorb blocked request threads, though waiting threads consume resources.
Resource expectations Aims to scale with a small, fixed number of threads and less memory under suitable workloads; this is an architectural goal, not a guaranteed capacity or benchmark result. Blocking workloads commonly rely on more request threads to handle concurrent waits.
Programming model Reactive, declarative programming has a learning curve, and blocking boundaries require care. Often fits conventional synchronous application code more directly.

Non-blocking does not generally make an application execute its business logic faster. The case for WebFlux is strongest when the workload is latency-heavy, its dependencies support non-blocking I/O, and reduced thread and memory pressure matters enough to justify the reactive programming model. If the application is centered on blocking libraries, adopting WebFlux without changing those dependencies may add complexity without delivering the intended benefit. These are workload-dependent trade-offs, not a universal ranking of the two stacks.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.