Search code examples
spring-cloudspring-cloud-gateway

Spring Cloud Gateway blocking requests for route descovery


I'm using Spring Cloud Gateway from spring-cloud-starter-gateway version 2.1.0.RELEASE and I need to understand why Gateway is blocking requests to perform the DiscoveryClientRouteDefinitionLocator process.

Spring Cloud Version: Greenwich.RELEASE.

I have two environments: staging and production.

In production we have a working gateway with the following latency for /actuator/health call:

production gateway

I was investigatinng why those spikes occurs on a simple health call and I figure out the gateway blocks any requests sometimes (even health or real microservices call) to perform discovery routes of all my microservices.

We use Consul for discovery server and I tried to test this latency at my staging environment (with way less hardware resource on Consul). The impact of this block is clear:

staging gateway

After improving the Consul hardware resources we have no more spikes but the latency still is not perfect (and have minor spikes to discovery all routes) for a health call:

upgraded staging gateway

I need to ask: why Spring Cloud Gateway is blocking requests even having caching feature? Should not this process run in the background? What I'm doing wrong? Its really an issue with Spring Cloud Gateway?

Thank you.


Solution

  • As discussed here previous version of Spring Cloud Gateway was using a blocking discovery-client.

    Using versions newer than 2.1.5.RELEASE will result in a more asynchronous gateway that doesn't do many blocking requests.