Spring MVC (async) vs Spring WebFlux

前端 未结 2 765
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-30 19:58

I\'m trying to understand Spring WebFlux. The things I\'ve found so far are reactive at the core, no Servlet API, no thread per request, HTTP 2, server pushes, application/strea

2条回答
  •  不要未来只要你来
    2021-01-30 20:58

    Servlet API is blocking I/O which requires 1 thread per HTTP request. Spring MVC async relies on Servlet APIs which only provides async behavior between container threads and request processing threads but not end to end.

    Spring WebFlux on the other hand achieves concurrency by a fixed number of threads by using HTTP sockets and pushing chunks of data at a time through the sockets. This mechanism is called event loop, an idea made popular by Node.js. Such an approach is scalable and resilient. Spring 5's spring-webflux uses the event loop approach to provide async behavior.

    More can be read from

    • Servlet vs. Reactive
    • Spring Boot performance battle
    • Comparing WebFlux with Spring Web MVC

提交回复
热议问题