Services fuse (Hystrix, Turbine)

1. avalanche

In the micro-service architecture, many services, often involving more than one service call level, once the failure of basic services, is likely to lead to cascading failures, and cause the entire system is not available, a phenomenon called avalanche effect service. Services avalanche effect is a result of "service provider" is not available leading to "serve the consumer" is not available and will not be available this gradual amplification process.
For example, in one system, A is the service provider: B A consumer with a service, C and D and B are the service consumers. If A fails at this time, it will cause the B unavailable, and in turn lead to unusable B C and D are not available, this is not available when a snowball is gradually enlarged when the avalanche effect is formed.

2. Fuse (CircuitBreaker)

Fuse principle is very simple, as the power overload protection. It can be implemented quickly fail if it detects many similar errors over a period of time, it will be forced to call more quickly after a failure, no longer access a remote server in order to prevent the application constantly try to perform may fail operation so that the program continues without waiting for the error correction, or a waste of CPU time to produce a long wait for a timeout. Fuses can also enable an application to diagnose whether an error has been corrected, if already amended application attempts to call the operation again. Fuse pattern like those one kind of proxy error-prone operation. This agent is able to record the number of errors recent call occurs, then decided to allow the operator to use the continuation, or an error is returned immediately. Fuse is a high-availability protection services last line of defense.

3.Hystrix properties

3.1 breaker mechanism

Circuit breakers is well understood that, when a backend service Hystrix Command requests the number of failures exceeds a certain percentage (default 50%), the circuit breaker will switch to an open state (Open). In this case all requests are not sent directly to the rear end of failure service. Holding the circuit breaker open state after a period of time (5 seconds by default) automatically switches to the half-open state (HALF-OPEN). In this case a request to return the situation will determine if the request is successful, the closed state of the circuit breaker switch back ( CLOSED), or switch back to the open state (oPEN) .Hystrix circuit breaker is like our family in the fuse, once the back-end service is not available, the circuit breaker will cut off direct request chain, to avoid sending a large number of invalid requests, thus affecting system throughput, and the ability to self-testing circuit breaker and recovery.

3.2 fallback

fallback equivalent to downgrade. For query operation, we can achieve a fallback method, when the back-end service request an exception, you can use the value fallback method returns. fallback return value is typically set to a default value or from the buffer.
3.3 resource isolation

In Hystrix, the main resource isolation is achieved by the thread pool, usually when we use the thread pool will be divided according to multiple remote service call. For example, calling into goods and services Command A thread pool, call the Command account services into the thread pool B, the main advantage of this is that the operating environment was set apart. So even if the code to call the service a bug or due to other causes where their thread pool is exhausted, nor will it affect other services system, but the cost of bringing the thread pool is to maintain multiple systems will bring additional performance overhead. If there are strict performance requirements and make sure their own client code to invoke the service will not be a problem, you can use Hystrix signal pattern (Semaphores) to isolate resources.

5.Hystrix Dashboard

Hystrix-dashboard is a tool for real-time monitoring of Hystrix by Hystrix Dashboard, we can visually see each Hystrix Command request response time, success rate request data.

6.Spring Cloud  Turbine

Above we integrate Hystrix Dashboard, use Hystrix Dashboard can see the service information within a single application. Obviously this is not enough, we need a tool that allows us to aggregate data multiple services within the system and displayed on Hystrix Dashboard, this tool is Turbine.

Guess you like

Origin www.cnblogs.com/xc-xinxue/p/12543555.html