Default number of threads in Spring boot 2.0 reactive webflux configuration

99封情书 提交于 2019-12-22 11:07:04

问题


While using Spring 5 reactive webflux with Spring boot 2.0, what's the default number of threads used to handle requests? How can I configure the number of threads used?


回答1:


The default number of threads for request handling is determined by the underlying web server; by default, Spring Boot 2.0 is using Reactor Netty, which is using Netty's defaults (check out the EventLoopGroup documentation for that).

Spring Boot will soon allow you to customize that part (see #10418). In the meantime, you can provide your own ReactiveWebServerFactory bean and change that through the HttpServer configuration options (see this comment).




回答2:


Currently, it seems that Spring Webflux 2.0 does not provide the ability to control threads.

Spring Webflux 2.0 is using Reactor-Netty. And ReactorNettyclass provides some configurations.

  • reactor.netty.ioWorkerCount
  • reactor.netty.ioSelectCount
  • reactor.netty.pool.maxConnections
  • etc

So, You can use it like this.

System.setProperty("reactor.netty.ioWorkerCount", "100");

I hope that Spring Boot will provide a custom configuration.



来源:https://stackoverflow.com/questions/46925508/default-number-of-threads-in-spring-boot-2-0-reactive-webflux-configuration

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!