| Spring MVC | Spring WebFlux | |
|---|---|---|
| Model | Thread-per-request (blocking) | Non-blocking, event-driven |
| Server | Tomcat/Jetty (Servlet) | Netty |
| Handler trả về | Giá trị trực tiếp (User) | Mono<T> / Flux<T> |
| DB | JPA, Hibernate, JDBC | R2DBC, Reactive Mongo |
| Concurrency | ~5K (thread pool) | 100K+ (thread pool nhỏ) |
| Debug | Stack trace rõ | Khó hơn (async chain) |
Chọn WebFlux: high-concurrency I/O-bound (chat, streaming, SSE), gateway forward nhiều request đồng thời, cần backpressure.
Giữ MVC: CPU-bound (WebFlux không giúp), dùng JPA/Hibernate (chưa có reactive equivalent trưởng thành), team chưa quen reactive — debug Mono/Flux khó.
Quan trọng 2026: Virtual Threads (Java 21) giúp MVC đạt concurrency tương đương WebFlux mà vẫn code đồng bộ → nhiều team quay về MVC. Bật: spring.threads.virtual.enabled=true.