Hystrix (fuse)

When the service provider responds very slowly, it is forced to wait for the consumer's request to the provider until the provider responds or times out. In high-load scenarios, if nothing is done, such problems may lead to resource exhaustion of service consumers and even the collapse of the entire system (avalanche effect). Hystrix can effectively prevent such problems from happening. Hystrix is a delay and fault-tolerant library open sourced by Netflix, which is used to isolate access to remote systems, services or third-party libraries, prevent cascading failures, and improve system availability and fault tolerance. Hystrix mainly achieves latency and fault tolerance through the following points:

(a) Wrap request: Use HystrixCommand (or HystrixObservableCommand) to wrap the calling logic of dependencies, and each command is executed in an independent thread. This uses the "command pattern" from Design Patterns.

(b) Tripping mechanism: When the error rate of a service exceeds a certain threshold, Hystrix can automatically or manually trip and stop requesting the service for a period of time.

(c) Resource isolation: Hystrix maintains a small thread pool (or semaphore) for each dependency. If the thread pool is full, the request sent to the dependency will be rejected immediately instead of waiting in the queue, thus speeding up the failure determination.

(d) Monitoring: Hystrix can monitor running indicators and configuration changes in near real time, such as success, failure, timeout, and rejected requests.

(e) Fallback mechanism: execute fallback logic when a request fails, times out, is rejected, or when a circuit breaker is opened. The fallback logic can be specified by the developer.

Last updated