I have an application which connects to third party service and gets the result back to client. Inside , app make an GET request to third party service and gets the result. I have used Reactor and reactive code to scale the application at heavy loads. This is a Spring Boot project which runs embedded Tomcat and relies on Web Client( Reactive netty for making request to third party). Somehow , CPU Utilization and response times are worse than blocking mode. The hardware setup has single core running in Kubernetes.
The project is set up inside Kubernetes and running on single pod with one core. I tried in reactive way , but the app is much slower and even CPU Utilization is high when compared to blocking architecture.
public Mono<ResponseEntity<?>> get(HttpServletRequest request)
{
return Mono.create ( callback -> {
Mono<Response> response = Make HTTP GET Call using webClient.
response.subscribe(response -> {
callback.success(response);
},error -> {
callback.error(error);
}
});
}
With Traditional Blocking mode , I am ble to see better performance and decreased CPU usage when comapred to reactive approach. What could be the reason for this disparity ? Is it because of context switching as there is only one core ? If yes , how do we attain better performance through single core architecture ?