Hystrix of spring cloud

In the microservice architecture, microservices are highly dependent on each other, and calls between them will inevitably fail. However, when downstream service a collapses due to instantaneous traffic, other B and C services that depend on service a consume a lot of resources due to the timeout of calling service A. for a long time, B and C services will also collapse. Hystrix is a fuse used to solve the failure of mutual calls between services, avoid butterfly effect, and provide degradation options. Hystrix achieves this goal by isolating access points between services, preventing cascading failures between them, and providing default options to improve the overall robustness of the system.

What problems does it mainly solve? It is used to avoid large-scale service avalanche caused by individual service downtime and service suspension due to heavy dependence between services.

1、 Maven dependency

2、 Startup class configuration

3、 Modify the configuration file (application. YML)

4、 Test class

5、 Test effect

You can also customize the fallback to realize the return value, but I think the default looks better, so I can directly default it.

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
分享
二维码
< <上一篇
下一篇>>