Search code examples
spring-bootnetflix-zuulnetflix-eurekahystrix

Hystrix Circuit Breaker Implementation be at Zuul API Gateway Level or at REST API Service Level


For Example, I have two Rest Api services running

  1. https://my-app-one.com/get
  2. https://my-app-two.com/update

After Zuul API Gateway Implementation the requests will be routed to

Zuul Proxy:

Proxy 1 : https://zuul-api-gateway.com/get Proxy 2 : https://zuul-api-gateway.com/update

Questions:

  1. Can we implement Hystrix Dashboard at Zuul API gateway level?
  2. Can we utilize all Hystrix commands if implemented at API gateway level?
  3. What are the challenges and please provide documentation or examples.

I already have a working example of Hystrix Circuit Breaker and Hystrix Dashboard. All I want to know is if I can move Hystrix implementation at Zuul API gateway level.


Solution

  • @IMNash: Unfortunately, I cannot comment to your original question so I am afraid I have to ask you via an Answer. I am terribly sorry that I need to do that but I don't have enough reputation points yet.

    Is it mandatory for you to go the Zuul way? If not, you might want to consider using Spring Cloud Gateway. The relevant post from Baeldung is an eye opener. See the below snippet:

    //...route definition
    .route(r -> r.path("/articles")
       .filters(f -> f.hystrix("some-command"))
       .uri("http://baeldung.com")
       .id("hystrix_route")
    

    I have tested this myself and yes, it's that easy to apply Hystrix. The next step would be to configure the Hystrix filter as per your needs (e.g. timeouts, max semaphores, etc.).