简体   繁体   中英

Resilience4j vs Hystrix. What would be the best for fault tolerance?

When I initially learn about spring boot, I've learnt about spring cloud netflix hystrix as a circuit breaker. There were bunch of options such as multiple application properties and annotation base declarations for fault tolerance. In-addition to that, it has few important threshold values as well. Most importantly hystrix the data can be prompted to hystrix dashboard via hystrix streams . With the use of turbine we can combine multiple hystrix streams and overview microservices. That is my experience from hystrix .

Now I have a requirement to implement Resilience4j which is basically supporting the same behaviour for fault tolerance. I am new to Resilience4j and I would like to know the main difference of these two fault tolerance options before getting started. According to my research Resilience4j is a robust option than hystrix . I would be grateful to know the expert facts and thank you.

The most prominent difference between the two is the fact that while Hystrix embraces an Object-Oriented design where calls to external systems have to be wrapped in a HystrixCommand offering multiple functionalities, Resilience4J relies on function composition to let you stack the specific decorators you need.

Since, Resilience4J is a standalone library inspired by Hystrix but build on the principles of Functional Programming. Resilience4J will be the best option to handle fault tolerance.

I can say it really does not matter what implementation you choose unless there are specific requirements that would favor a particular implementation. I would pick rather anything from Netflix Hystrix as it is in a maintenance mode as of 2018 ( https://spring.io/blog/2018/12/12/spring-cloud-greenwich-rc1-available-now ). Read the Hystrix status at GitHub: https://github.com/Netflix/Hystrix#hystrix-status .

Let me emphasize this: "What I find more important from the architectural point of view is to enable an environment where is easy to replace such implementation as needed."

I can recommend using Spring Cloud Circuit Breaker as a framework that has a consistent API and allows developers to pick the implementation: Netflix Hystrix, reactive or non-reactive Resilience4j, Sentinel, and Spring Retry.

All can be configured as necessary and all provide a basic default configuration to change value thresholds, slow call thresholds, sliding window size, etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM