简体   繁体   English

WebFlux - Reactor Http Epoll 线程

[英]WebFlux - Reactor Http Epoll threads

I am using Spring webflux.我正在使用 Spring webflux。 I send hundreds of concurrent requests to the rest end point.我向 rest 端点发送了数百个并发请求。 When I checked, only 4 threads are being shared to handle all the loads.当我检查时,只有 4 个线程被共享来处理所有负载。

Is this normal?这是正常的吗? Is there any spring property to increase this count?是否有任何 spring 属性可以增加此计数?

  • reactor-http-epoll-1反应器-http-epoll-1
  • reactor-http-epoll-2反应器-http-epoll-2
  • reactor-http-epoll-3反应器-http-epoll-3
  • reactor-http-epoll-4反应器-http-epoll-4

I do understand that I could use reactor Schedulers to offload the blocking work.我知道我可以使用反应堆调度程序来卸载阻塞工作。 My question is more of - what are these 4 threads and where do we have this configuration?我的问题更多 - 这 4 个线程是什么,我们在哪里有这个配置?

The number of default threads is dependent on the core count of the host system.默认线程数取决于主机系统的核心数。

Remember, Webflux will try to keep said threads as busy as possible, so how many threads you have assigned doesn't really matter, as long as they consume the full power of the CPU.请记住,Webflux 会尽量让上述线程保持忙碌,因此您分配的线程数并不重要,只要它们消耗 CPU 的全部能力即可。

More threads will just have to wait for their turn to use the CPU.更多线程将只需要等待轮到它们使用 CPU。

If performance is a concern, there are multiple ways to gain better performance, for example by having multiple systems with a load balancer infront, or more cpu cores, and also try to profile what takes time in the application.如果性能是一个问题,有多种方法可以获得更好的性能,例如让多个系统在前面有一个负载平衡器,或者更多的 cpu 内核,并且还可以尝试分析应用程序中什么需要时间。

It is very hard to know what is taking time since you have posted nothing about your setup.由于您没有发布任何关于您的设置的信息,所以很难知道什么是花费时间。 There could be bottlenecks like rest calls to other systems that are slow, multiple database connections, large queries, lots of data processing etc. etc.可能存在瓶颈,例如 rest 对其他系统的缓慢调用、多个数据库连接、大型查询、大量数据处理等。

But what you are seeing is quite normal, and is answered here:但是你所看到的是很正常的,并在这里得到回答:

threading-model-of-spring-webflux-and-reactor spring-webflux-and-reactor 的线程模型

Webflux concurrency model Webflux 并发 model

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM