I have a rest spring application which makes external API calls to other internal services. This is a high load/concurrency app where it gets 100s of request per second.
I am using Spring webClient (webflux) to make external API calls from my Service layer.
Traditionally, I have used a separate thread pool for my service method where I return CompletableFuture
which is also returned from my controller layer (which trigger async mechanism in Spring Web). That way, I could not control the concurrency level at service level (by tweaking the threadpool size) but also release the Tomcat Thread as soon as service method is called!.
I am wondering if I can skip using separate threadpool for the service layer and return Mono
from the service and from controller and let the reactive Event loop handle all concurrency for me. Is there is any advantage here to us Mono (Reactive stack) vs using dedicated Thread pool for service layer?
Also – could the hybrid approach be an option where I keep using separate threadpool for the service layer and return CompletableFuture from the service and controller layer?