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 blocking input/output streams. The Servlet 3.1 container has evolved further, supporting asynchronicity and having the non-blocking I/O stream APIs. However, there are certain Servlet APIs, such as request.getParameters()
, which parse the blocking request body 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 backpressure 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 logic. Writing...