Exploring Spring WebFlux
Existing Servlet APIs are blocking APIs. They use input and output streams, which block APIs. Servlet 3.0 containers evolve and use the underlying event loop. Async requests are processed asynchronously but read and write operations still use the input/output streams that are blocking. The Servlet 3.1 container evolves further and supports asynchronicity, and has the non-blocking I/O stream APIs. However, there are certain Servlet APIs, such as request.getParameters()
, that parse the request body that is blocking and provide synchronous contracts such as Filter
. The Spring MVC framework is based on the Servlet API and Servlet containers.
Therefore, Spring provides Spring WebFlux, which is fully non-blocking and provides back-pressure functionality. It provides concurrency with a small number of threads and scales with fewer hardware resources. WebFlux provides fluent, functional, and continuation-style APIs to support the declarative composition of asynchronous...