> Markdown version of [/videos/345-going-reactive-with-spring-webflux](https://www.wearedevelopers.com/videos/345-going-reactive-with-spring-webflux). Every page supports `.md` or `Accept: text/markdown`. Links point to the HTML versions so they work for humans too. Agent guide: [/agents.md](https://www.wearedevelopers.com/agents.md). --- # Going reactive with Spring WebFlux Are your APIs choking under heavy workloads? Learn how to adopt Spring WebFlux's non-blocking architecture and safely integrate legacy blocking databases without crashing your system. - **Speakers:** Michael Eder, Philipp Frauenthaler - **Event:** WeAreDevelopers LIVE - **Published:** February 1, 2022 - **Duration:** 54:18 - **URL:** https://www.wearedevelopers.com/videos/345-going-reactive-with-spring-webflux ## Summary Spring WebFlux introduces a paradigm shift from the traditional, blocking thread-per-request model of Spring MVC to a highly efficient, non-blocking event loop architecture. Likened to a restaurant where waiters continuously serve guests instead of waiting idly in the kitchen, WebFlux utilizes a small pool of threads that handle requests asynchronously. This reactive approach, built on Project Reactor with publishers like Mono and Flux, aims to maximize resource utilization and improve response times under heavy database or API workloads. Transitioning to a reactive stack requires a functional programming style and careful management of threading, especially when integrating legacy blocking libraries. In a large-scale real-world platform, the speakers adopted a hybrid model. Because native reactive data access frameworks like Hibernate Reactive and Spring Data R2DBC were still maturing at the time, they safely integrated blocking Spring Data JPA calls by offloading them to a bounded elastic thread pool. This crucial pattern prevents the fatal mistake of blocking the main event loop, while custom transaction management ensures data integrity across asynchronous context boundaries. While Spring WebFlux drastically improves scalability, it introduces significant complexity and a steep learning curve. Developers must abandon imperative habits to manually manage thread safety, subscription contexts, and backpressure. Additionally, debugging reactive pipelines can be notoriously difficult due to fragmented and misleading stack traces. The ultimate takeaway is that while a fully reactive stack from the API down to the database is ideal, hybrid models are completely viable as long as engineering teams rigorously enforce non-blocking principles and properly isolate synchronous tasks. **Keywords:** spring webflux, spring MVC, reactive programming, project reactor, event loop architecture, thread-per-request model, non-blocking IO, mono and flux publishers, spring data R2DBC, hibernate reactive, spring data JPA, bounded elastic thread pool, asynchronous transaction handling, spring webclient, reactive debugging challenges, backpressure management ## Chapters 1. **Differences between Spring MVC and Spring WebFlux** (00:02) — How synchronous and asynchronous request processing differ in the Spring framework. 1. **Explaining request models using a restaurant metaphor** (02:58) — How waiter efficiency illustrates the difference between thread-per-request and event loops. 1. **Thread per request versus event loop execution** (05:59) — Why traditional synchronous applications waste resources waiting on database interactions. 1. **Understanding publishers, subscribers, and signals in WebFlux** (09:23) — How Mono and Flux handle data emission and functional programming operations. 1. **Designing a reactive API layer with Mono publishers** (14:03) — Converting a traditional Spring MVC controller to a non-blocking functional endpoint. 1. **Managing business logic and thread blocking in WebFlux** (19:49) — Using a bounded elastic thread pool to prevent blocking the main event loop. 1. **Implementing safe transactional boundaries in asynchronous code** (22:47) — Managing explicit transaction status checks when declarative annotations fail in reactive contexts. 1. **Choosing native reactive libraries for data access layers** (30:39) — An overview of Hibernate Reactive, R2DBC, and Spring Data implementations. 1. **Executing non-blocking HTTP requests with Spring WebClient** (35:19) — How to make external API calls without blocking the reactor HTTP NIO threads. 1. **Implementing a hybrid reactive architecture in production** (38:10) — Applying reactive API patterns while integrating with synchronous database repositories. 1. **Weighing architectural complexity against system performance benefits** (41:15) — Why migrating to WebFlux requires committing to an entirely reactive tech stack. 1. **Answering questions on thread safety and reactive debugging** (43:10) — Exploring common pitfalls involving shared state, completable futures, and stack trace readability. ## Related Moments - [Comparing Spring WebFlux and Spring MVC stacks](https://www.wearedevelopers.com/videos/69-slip-through-the-boundaries-of-legacy-systems-with-kotlin-and-spring-webflux) (from "Slip Through the Boundaries of Legacy Systems with Kotlin and Spring WebFlux") - [Adopting Spring WebFlux and the Reactor API](https://www.wearedevelopers.com/videos/440-back-end-to-the-future-embracing-the-continuous-evolution-of-infrastructure-and-code) (from "Back(end) to the Future: Embracing the continuous Evolution of Infrastructure and Code") - [Framework adoption challenges in the reactive programming ecosystem](https://www.wearedevelopers.com/videos/668-side-by-side-reactive-vs-non-reactive-java) (from "Side-by-Side: Reactive vs non-reactive Java") - [Building scalable applications with reactive programming](https://www.wearedevelopers.com/videos/383-kubernetes-native-java) (from "Kubernetes Native Java") - [Refactoring data processing pipelines using Spring WebFlux streams](https://www.wearedevelopers.com/videos/668-side-by-side-reactive-vs-non-reactive-java) (from "Side-by-Side: Reactive vs non-reactive Java") - [Solving thread blocking with reactive frameworks and Kotlin](https://www.wearedevelopers.com/videos/993-java-s-project-loom-co-the-end-for-reactive-programming) (from "Java's Project Loom & Co - the end for reactive programming?") ## Related Articles - [Why Event-Driven Architecture Isn’t About Speed (and When You Actually Need It)](https://www.wearedevelopers.com/magazine/745-why-event-driven-architecture-isn-t-about-speed-and-when-you-actually-need-it) - [Why You Shouldn’t Build a Microservice Architecture](https://www.wearedevelopers.com/magazine/118-why-you-shouldn-t-build-a-microservice-architecture) - [Web Development Best Practices: What The Data Tells us](https://www.wearedevelopers.com/magazine/84-web-development-best-practices-what-the-data-tells-us) - [Dev Digest 132 - Binging WADFlix?](https://www.wearedevelopers.com/magazine/473-dev-digest-132-binging-wadflix) ## Related Jobs - [Mid/Senior Full-Stack Engineer (Web-first)](https://www.wearedevelopers.com/jobs/ext/1210833-mid-senior-full-stack-engineer-web-first) at **SMG Swiss Marketplace Group** - [Senior Software Engineer, React (Broker Web Platform)](https://www.wearedevelopers.com/jobs/ext/2770117-senior-software-engineer-react-broker-web-platform) at **Bitpanda** - [Senior Software Engineer, React (Investing & Trading)](https://www.wearedevelopers.com/jobs/ext/1937625-senior-software-engineer-react-investing-trading) at **Bitpanda** - [Sr Architect - Emerging Technologies](https://www.wearedevelopers.com/jobs/ext/2863027-sr-architect-emerging-technologies) at **Twilio** - [Software Engineer, Angular (B2C Web Platform)](https://www.wearedevelopers.com/jobs/ext/3047993-software-engineer-angular-b2c-web-platform) at **Bitpanda** - [Senior Software Engineer, Angular](https://www.wearedevelopers.com/jobs/ext/2796428-senior-software-engineer-angular) at **Bitpanda**