Why this matters
- Choosing WebFlux for a CRUD BookStore API adds Project Reactor complexity without benefit if every endpoint blocks on JPA anyway.
- WebFlux shines when you proxy slow upstream APIs, stream large result sets, or compose many I/O calls without blocking threads.
- Virtual threads on Java 21+ give most MVC apps reactive-scale concurrency without rewriting controllers to return
MonoandFlux.
Blocking vs reactive
L1 · FresherMVC uses threads per request; WebFlux uses event loops and Mono/Flux return types.
Netty on WebFlux
L2 · IntermediateWebFlux runs on Reactor Netty by default — do not block on JDBC inside reactive chains.
When to pick WebFlux
L3 · AdvancedHigh concurrency I/O to many slow clients or streaming SSE — not default CRUD BookStore APIs.
Hybrid pitfalls
L4 · ExpertCalling .block() in WebFlux or mixing MVC and WebFlux in one app without clear boundaries causes thread starvation.
Blocked virtual threads release their carrier — other virtual threads continue
MVC vs WebFlux decision factors
- Thread model — MVC: one platform (or virtual) thread per request. WebFlux: event loop with non-blocking I/O.
- Return types — MVC: plain objects,
ResponseEntity. WebFlux:Mono<T>,Flux<T>. - Database access — JPA is blocking; WebFlux needs R2DBC or offloads blocking calls to a separate pool.
- Ecosystem fit — MVC has mature Spring Data JPA, security, and validation. WebFlux requires reactive drivers throughout.
- Backpressure — WebFlux supports flow control for streaming; MVC buffers the full response.
Typical MVC controller (blocking, simple)
// learn:fragment
@RestController
@RequestMapping("/api/books")
public class BookController {
private final BookService bookService;
public BookController(BookService bookService) {
this.bookService = bookService;
}
@GetMapping("/{isbn}")
public BookDetail getBook(@PathVariable String isbn) {
return bookService.getByIsbn(isbn);
}
@GetMapping
public List<BookSummary> search(@RequestParam String query) {
return bookService.search(query);
}
}
The rest of this guide is part of Pro
Free covers every fresher guide in full. Pro unlocks Senior, Staff and Architect guides across every track.
Still to come · 2 sections
- WebFlux controller (non-blocking)
- Composing non-blocking upstream calls
Test yourself
Answer these before moving on — recall is what makes it stick.