spring-cloud / spring-cloud-gateway

An API Gateway built on Spring Framework and Spring Boot providing routing and more.
http://cloud.spring.io
Apache License 2.0
4.49k stars 3.31k forks source link

Timeout for Eureka Registered Services #2695

Open aakashkarira opened 2 years ago

aakashkarira commented 2 years ago

Right now, we can configure timeout (connect, response) for individual routes configured in our application.yml, but there is no provision to set timeouts for route configured via Eureka. When we enable the discovery client we can route to other services registered on same eureka server. In our usecase, we want to configure individual timeouts for different services. Tried overriding route by passing same routeid : ReactiveCompositeDiscoveryClient but doesn't seems to work.

Simple hack we are doing right now is explicitly defining route for services for which we need different timeout and setting order with higher precedence with a downside of having multiple entries for same route (obviously with different precedence)

We were able to configure timeout with ribbon easily in zuul, however in spring cloud gateway & loadbalancer this doesn't seems to be possible.

Is there any plan around this?

spencergibb commented 1 year ago

I believe if you set it in eureka metadata, it will be set in gateway. https://github.com/spring-cloud/spring-cloud-gateway/blob/9d60f165868126a1dfd8ebbf94dda2619934e5a3/spring-cloud-gateway-server/src/main/java/org/springframework/cloud/gateway/discovery/DiscoveryClientRouteDefinitionLocator.java#L138

aakashkarira commented 1 year ago

Yes agreed, it can be achieved by updating metadata. But when we have N number of services registering on Eureka, updating timeouts in metadata of each service in respective configuration becomes cumbersome. Handling this timeout configuration in gateway will provide flexibility for those services which all want timeouts different from default configured.