What is Hystrix?
In a distributed environment, some unavoidable services fail, and hystrix can control the interaction between distributed services by delaying tolerance and error tolerance logic. Hystrix can isolate service access ingress, suppress cascading errors,
Support fallback, all of which can improve the overall elasticity of the system (resiliency).
What Hystrix to do
Protection and control of delays and errors in access services;
Suppress cascading errors in complex distributed systems;
Rapid failure and rapid recovery;
fallback and downgrade;
Near real-time monitoring, alerting and operation control.
What problems can hystrix solve
In a complex distributed system, there are often many service dependencies, and inevitably service failures. Assuming an application relies on 30 services, each service is normal at 99.99% uptime and can be calculated as:
99.99e30 = 99.7% Uptime
0.3% of 1 billion requests = 3,000,000 failures
Hours Downtime/month Even if all dependencies has excellent uptime (99.99%).
When all services are healthy, the request flow is this:
A back-end system produces a delay that affects the user's entire request:
Depending on the service Lib is a "black box", most of it will make network requests, but even worse, the service system may also rely on other services. In high-throughput applications, a service-dependent delay can deplete the entire server resource in seconds:
Hystrix How to solve the problem
Hystrix can wrap service calls in Hystrixcommand, each Hystrixcommand maintains a threadpool to isolate the service, and when a service produces a delay, its "engulfing" Resources are only limited to the Hystrixcommand (for example, at most only n thread resources), without affecting the global. Dependent Threadpool,hystrix can also implement a timeout operation. At the same time, when the request time-out, exception, line Cheng, fuse open, Hystirx can fallback.
netflix-hystrix-Introduction [Translate]