Resilience4j and Sentinel: Two Open-Source Alternatives to Netflix Hystrix

Seeking “fault tolerance” for microservices in novel ways

This article is part of the Alibaba Open Source series.

As microservices become more popular, the stability between services becomes more and more important. Technologies such as flow control, fault tolerance, and system load protection are widely used in microservice systems to improve the robustness of the system and guarantee the stability of the business, and to minimize system outages caused by excessive access traffic and heavy system load.

Hystrix, an open source latency and fault tolerance library of Netflix, has recently announced on its GitHub homepage that new features are no longer under development. It is recommended that developers use other open source projects that are still active.

According to Hystrix’s official GitHub:

Netflix opened Hystrix, the fault tolerance library, in 2012. Hystrix contributes to the promotion of the concept of “fault tolerance” for microservices, and spreads the concept of isolation and tolerance to a wide range of developers. For a long time, whenever it comes to isolation and fault tolerance, developers first think of Hystrix. By 2014, Netflix had a full march into Spring Cloud, and a series of Netflix’ microservice components also came into the developers’ view along with Spring Cloud Netflix. At the same time, Hystrix made a major refactoring of the underlying statistical structure by using RxJava, fully embracing RxJava. Hystrix has long been a popular fault tolerance library across the industry, but the community activity has been declining. Recently, Hystrix suddenly came to a screeching halt and announced to stop maintenance.

Resilience4j and Sentinel are also available as flow limiting open source products that are compatible with the Spring Cloud ecology.

Resilience4j is a lightweight fault tolerant library inspired by Netflix Hystrix, but designed for Java 8 and functional programming. The library is lightweight, because it only uses Vavr (formerly known as Javaslang) and has no other external library dependencies. By contrast, Netflix Hystrix has a compilation dependency on Archaius, which has more external library dependencies, such as Guava and Apache Commons configurations.

Compared with Hystrix, Resilience4j has the following advantages:

  1. For Java 8 and functional programming, it provides a functional and responsive API;
  2. It adds two modules, Rate Limiting and Automatic Retrying. Rate Limiting introduces a simple implementation of rate control, which complements the function of flow control. Automatic Retrying encapsulates the logic of automatic retry, which simplifies the process of exception recovery.

Sentinel, a lightweight and highly available flow control component for distributed service architectures, officially went open source in July of this year. Sentinel mainly takes the flow as the breakthrough point to help users improve the stability of services from multiple dimensions such as flow control, fault tolerance and system load protection.

Compared with Hystrix, which focuses on isolation and fault tolerance, Sentinel focuses on various scenarios such as flow shaping, system protection and fault tolerance, and on specialized scenarios such as spikes in pulse flow, the continuous flow peaks at midnight on Double Eleven, the automatic detection and control of popular commodities, peak load shifting, the cluster flow limiting for uneven distribution of clusters, cold start and the adaptive system protection based on capacity and flow.

In terms of rule management and monitoring, both Hystrix and Sentinel support dynamically adding and modifying rules and provide interfaces to allow users to scale. Hystrix relies on Archaius for dynamic configuration reading and management by default, while Sentinel provides dynamic rule source support such as Nacos, Apollo, ZooKeeper and Redis. Both Hystrix and Sentinel provide a console to display real-time monitoring data (such as QPS, average response time) for the application, but the user experience and focus are completely different. For example, Hystrix provides percentile statistical analysis; while Sentinel displays local call links in addition to providing real-time monitoring.

To know more:

Resilience4j

Sentinel

Alibaba Tech

First hand and in-depth information about Alibaba’s latest technology → Facebook: “Alibaba Tech”. Twitter: “AlibabaTech”.

First-hand & in-depth information about Alibaba's tech innovation in Artificial Intelligence, Big Data & Computer Engineering. Follow us on Facebook!