Spring boot 2.0 active webflux配置中的默认线程数

问题描述 投票:3回答:2

使用Spring 5反应式webflux和Spring启动2.0时,用于处理请求的默认线程数是多少?如何配置使用的线程数?

spring spring-boot reactive spring-webflux
2个回答
6
投票

请求处理的默认线程数由底层Web服务器确定;默认情况下,Spring Boot 2.0使用Reactor Netty,它使用的是Netty的默认值(请查看EventLoopGroup文档)。

Spring Boot将很快允许您自定义该部分(请参阅#10418)。在此期间,您可以提供自己的ReactiveWebServerFactory bean并通过HttpServer配置选项进行更改(请参阅this comment)。


1
投票

目前,Spring Webflux 2.0似乎没有提供控制线程的能力。

Spring Webflux 2.0正在使用Reactor-Netty。而ReactorNettyclass提供了一些配置。

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

所以,你可以像这样使用它。

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

我希望Spring Boot能提供自定义配置。

© www.soinside.com 2019 - 2024. All rights reserved.