spring-bootspring-webfluxreactor-nettyspring-resttemplate

Decrease initial lag in webclient call


I am currently using Webclient of spring-webflux package to make synchronous REST calls.

But the time taken to mae the first request is longer than the time taken by RestTemplate.

I have observed that the successive calls take much lesser time and more or less same to that of RestTemplate.

Is there a solution to decrease the initial lag for Webclient?


Solution

  • By default, the initialization of the HttpClient resources happens on demand. This means that the first request absorbs the extra time needed to initialize and load:

    You can preload these resources - check this documentation

    Things that cannot be preloaded are: