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?
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