Issue with Spring Boot/Webflux APIs on Kubernetes

1 week ago 6
ARTICLE AD BOX

So I am working on building a spring boot application, which has some rest endpoints and in my service I am calling some other downstream API's using Webflux. All the calls are non-blocking, meaning I am not using anything with .block().

Here is some sample code:

Controller:

@PostMapping("/submit") public Mono<Response> submit(@Valid @RequestBody Request request, @RequestHeader HttpHeaders incomingHttpHeaders) { return service.processRequest(request, incomingHttpHeaders, Boolean.TRUE); }

Service:

public Mono<Response> callApi(Request request, HttpHeaders incomingHttpHeaders, boolean fetchType) { //logic to fetch the URI from properties WebClient.RequestBodySpec requestSpec = webClient.post().uri(endpoint); return requestSpec .bodyValue(request) .retrieve() .bodyToMono(Response.class); }

Now this code, works all fine. But the issue is when I am running a load test, then spring is unable to serve the health check endpoints. i.e. liveness and readiness probes and kubernetes thinks the service is not responding and it just restarts the service(which works as expected).

My time period to check the readiness and liveness endpoints is set to 45 seconds. And I am running the load test for around 2 mins with 50 VUs.

Is there anything else, that we need to configure in terms of spring?

Help appreciated.

Thanks!

Read Entire Article