spring-cloud / spring-cloud-netflix

Integration with Netflix OSS components
http://cloud.spring.io/spring-cloud-netflix/
Apache License 2.0
4.87k stars 2.44k forks source link

Questions regarding retrying HTTP requests #1967

Closed asarkar closed 7 years ago

asarkar commented 7 years ago

Based on @ryanjbaxter blog post Retrying HTTP Requests In Spring Cloud Netflix, and my own quest to understand how this works, I've the following questions:

  1. There are load balancing clients in Ribbon general, org.springframework.cloud.netflix.feign.ribbon.LoadBalancerFeignClient, for example, and third-party specific, org.springframework.cloud.netflix.ribbon.okhttp.OkHttpLoadBalancingClient, without any apparent link between them. I'd think that a load balancing Feign client would delegate to one of the third-party specific Ribbon client, like OkHttp, but that doesn't seem to be the case. Can you help me understand the design here?

  2. For retryable load balancing clients, since you're always instantiating the RetryTemplate, the user doesn't have a chance to use all the features of it, like exponential back off, for example. If you looked up one first from the context, users could supply their own RetryTemplate.

  3. It appears that with Hystrix enabled, I can't use Feign Retryer. Hystrix intercepts and throws an exception before the retryer gets it's chance. Is that correct or am I missing something?

  4. What's the Hystrix group key used by a Spring Cloud Feign client, since the @FeignClient annotation doesn't have an attribute to specify it? Debugging shows the group key is the same as the Feign client name.

  5. What's the Hystrix thread pool name used by a Spring Cloud Feign client, since the @FeignClient annotation doesn't have an attribute to specify it? Debugging shows the thread pool key is the same as the Feign client name.

ryanjbaxter commented 7 years ago
  1. There are currently 3 ways HTTP requests can be made in Spring Cloud Netflix. Feign, Zuul (via a proxy) and LoadBalanced RestTemplates. I understand your confusion since all 3 use Ribbon so it would seem logical that there would be a common "client" that is used by all. Unfortunately that is not the case as the moment so there different retryable versions of each as well. I am not sure of the history as to why there isn't a single client implementation that is used but it might be something to look into in the future.

  2. Yes I agree, this is covered in #1872.

  3. This depends on why Hystrix is intercepting the request. Might be worth opening a separate issue for this and providing more details (stack trace).

asarkar commented 7 years ago

Thanks @ryanjbaxter.

Regarding (1), opened https://github.com/spring-cloud/spring-cloud-netflix/issues/1999

Regarding (3), opened https://github.com/spring-cloud/spring-cloud-netflix/issues/1998