First acquainted with Hystrix of service degradation, fusing, and current limiting

Hystrix official website:

github.com/Netflix/Hystrix/wiki/How-To-Use

Hystrix main functions: service degradation fallback, service fuse break, service flow limit, near real-time monitoring

One: Service downgrade fallback, report an error or problem, immediately return a prompt to the client. Both the consumer and provider sides of hystrix can be added, usually on the consumer side

1. Why is there a service downgrade:

 

2. Ideas and key points of attention:

3. Provider 8001's specific practices: 

4. The consumer 80 operation example is exactly the same as the provider's approach, except that it will often be implemented by the consumer in the future:

 

5. Current problems:

 6. Solution: Configure a default method. If method A uses @HystrixCommand, there is no specific fallback method specified in it. When A fails, it will automatically follow the method configured by @DefaultProperties(de...).

 In the figure below, the paymentInfo_error() method has an error. It is a custom method, not a global method, because @HystrixCommand has a specific fallback method. If it is not specified, the global method will be used.

7. Another solution is to downgrade the wildcard service: 1). Write a class PaymentFallBacService to implement the service that consumers want to call. The class is the bottom method of all methods. 2). When calling the method in PaymentHystrixService, the annotation is as follows Figure configuration:

 

Two: service fuse break

 

1. Fuse state

 

2. Go directly to the code

 

3. Summary of specific configuration parameters in HystrixCommandProperties:

 

 

The service is fuse. In this example, an interface is called 10 times within 10s, and the failure rate reaches 60% and the trip is made. At this time, the fuse is open and the current service cannot be called anymore. If you continue to call, it will enter the bottom method, even if it is called correctly It will also enter the bottom of the pocket method; when the fuse is open for the duration of the set time windower, it will enter the semi-fuse state until the fuse is closed, and the service will not be fuse at this time. 

Three: service monitoring hystrixDashbrod (need to write a special monitoring service 9001 to monitor 8001):

1.

 2. Monitoring service 9001 is very simple, just add @EnableHystrixDashbord to a startup class to enable real-time monitoring:

The 3.8001 startup class is modified as follows: 

 4. Page display:

 

Guess you like

Origin blog.csdn.net/zhangleiyes123/article/details/106839502