简体   繁体   中英

How to enable Hystrix circuit breaker at zuul?

in my application we are using springboot microservices , with eureka registry, zuul api gateway, here assume I have 2 instances of payment-service, and the zuul is using ribbon for loadbalancing the /payment endpoint to the payment-service, when one node of the payment-service is unresponsive, and still registered with the eureka. here we have configured the hystrix circuit breaker at Zuul apigateway, but hystrix circuit breaker is not getting opened for the unresponsive node.

Zuul creates a Hystrix circuit breaker for each route (serviceId). It means that one Hystrix circuit breaker will be shared between your all instances of payment-services .

The circuit breaker that Zuul creates for each route is not for removing an unhealthy instance from the routing list. It is just for preventing Zuul's down that can be caused by one kind of service's down.

Assumed that you're using the default configuration for Hystrix. If you have 3 instances of payment service and 2 instances among 3 are down, the circuit breaker for payment-service will be opened (because the default threshold of failure to open circuit is 50%). It means that all traffic to your payment services (including your one healthy instance) from Zuul will be blocked.

The thing that you want - removing an unhealthy instance from the routing list - is the role of Ribbon . Ribbon define many interfaces to define its behavior like IRule, IPing. Some of them have the ability that you want.

通过将功能区更改为<ServiceName>: ribbon: NFLoadBalancerRuleClassName: com.netflix.loadbalancer.AvailabilityFilteringRule ,可以使用功能区实现<ServiceName>: ribbon: NFLoadBalancerRuleClassName: com.netflix.loadbalancer.AvailabilityFilteringRule https://github.com/Netflix/ribbon/wiki/Working-with-load-balancers

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM