WebFlux - Reactor Http Epoll threads
Asked Answered
C

1

5

I am using Spring webflux. I send hundreds of concurrent requests to the rest end point. When I checked, only 4 threads are being shared to handle all the loads.

Is this normal? Is there any spring property to increase this count?

  • reactor-http-epoll-1
  • reactor-http-epoll-2
  • reactor-http-epoll-3
  • reactor-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?

Cognizant answered 31/8, 2020 at 17:3 Comment(3)
yes this is normal, you can read more here. And just because you increase the amount of threads will probably not give you more performance, instead each thread will have to wait for CPU execution slots #45019986Persia
@ThomasAndolf , does it mean I have only 4 epoll threads to handle all the incoming requests and they are also used for processing the requests? What needs to be done if the request processing is little bit of time consuming? Schedulers is the only option?Cognizant
@ThomasAndolf Please add this as an answer, so that I could accept that.Cognizant
P
6

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.

More threads will just have to wait for their turn to use the 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.

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.

But what you are seeing is quite normal, and is answered here:

threading-model-of-spring-webflux-and-reactor

Webflux concurrency model

Persia answered 31/8, 2020 at 22:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.