Spring cloud uses hystrix to realize the method of service fault-tolerant protection of circuit breaker

In microservices, we divide the system into many service units, which are interdependent through service registration and subscription consumption. But what happens if some services go wrong?

For example, there are three services (ABC). A calls B, and B calls C. because of the network delay or the problem of C's own code, B fails to get a response, so B's request to call C will be suspended and wait.

In the case of highly concurrent access, these suspended threads cannot be released, blocking subsequent requests, and eventually causing B to hang up. By analogy, a may also hang up and crash the whole system.

In order to solve the whole problem, spring cloud uses hystrix for service fault-tolerant protection, including a series of protection functions such as circuit breaker and thread isolation. Today, let's see how to realize circuit breaker through hystrix.

1、 What is spring cloud hystrix? What is a circuit breaker?

Spring cloud hystrix is implemented based on the open source framework hystrix of Netflix. Its purpose is to provide strong fault tolerance for delay and failure by controlling those nodes accessing remote systems, services and third parties.

The circuit breaker is similar to the leakage circuit breaker used in the strong current box in our home. When the service unit fails (similar to the short circuit of electrical appliances), an error response is returned to the caller through the fault monitoring function of the circuit breaker (similar to fuse), so as to avoid waiting for a long time, so as to prevent the fault from spreading to the whole system.

2、 Without circuit breaker, the page shows

Remember the spring cloud introduction series 2: three services (Eureka / Hello service / Hello consumer) in service governance using Eureka? We conducted experiments based on this.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>