Part 14 · Applications

MVC, WebFlux and virtual threads: choose by constraints

Prerequisites: 01-ecosystem

Which I/O contract fits the execution model?

MVC: request execution; Blocking driver: JDBC / JPA; Virtual threads: cheap blocking waits; WebFlux: event-loop processing; Non-blocking driver: async I/O + demand. Connections: MVC to Blocking driver (imperative I/O); Virtual threads to Blocking driver (still bounded); WebFlux to Non-blocking driver (reactive pipeline)
Two valid styles; virtual-thread configuration is separate from choosing MVC. No universal performance ranking is implied. [S26] [S13] [S44]

Goal & mental model verified

MVC supports an imperative request model; WebFlux uses non-blocking composition and reactive backpressure. Mono represents zero-or-one values and Flux a sequence. Virtual threads provide a separate way to scale blocking waits.

[S26] [S13]

Worked example · design exercise synthesis

A JPA quote API fits MVC naturally. A streaming aggregator with non-blocking downstream clients may fit WebFlux. Wrapping a blocking JPA call in Mono does not make its I/O non-blocking.

[S26] [S13] [S44]

Engineering decision synthesis

Choose based on dependency APIs, concurrency pattern and team expertise. MVC with virtual threads can retain readable blocking code; WebFlux adds composition and scheduling discipline.

[S26] [S13] [S44]

Pitfall & diagnosis synthesis

Blocking an event loop can stall unrelated requests. A reactive return type alone does not identify the server stack, and virtual threads do not remove database limits.

[S26] [S13] [S44]

Improve & validate synthesis

Prototype the same realistic workload with bounded dependencies. Compare memory, tail latency and failure handling; adopt complexity only for a measured benefit.

[S26] [S13] [S44]
Keep this: Choose an execution model for your dependencies, not your fashion sense.
Check yourself: Does Mono.just(blockingCall()) defer that call?

No. The argument is evaluated immediately before Mono.just receives it.

Sources & further reading

  1. [S13] Virtual threads

    Oracle / OpenJDK · documentation · accessed 2026-10-09 · Java SE 25

    Supports: I/O concurrency; Do not pool virtual threads; Limit scarce resources

    Read the linked section to validate the mechanism and its version-specific constraints.

  2. [S26] WebFlux overview

    Spring project maintainers · documentation · accessed 2026-10-09 · Documentation retrieved 2026-10-09

    Supports: Non-blocking execution; Backpressure; MVC applicability

    Read the linked section to validate the mechanism and its version-specific constraints.

  3. [S44] REST clients

    Spring project maintainers · documentation · accessed 2026-10-09 · Documentation retrieved 2026-10-09

    Supports: RestClient; WebClient; HTTP service proxies; RestTemplate deprecated in Framework 7

    Read the linked section to validate the mechanism and its version-specific constraints.