Using Resilience4j for improved resilience
In a fairly large-scaled system landscape of cooperating microservices, we must assume that there is something going wrong all of the time. Failures must be seen as a normal state, and the system landscape must be designed to handle it!Initially, Spring Cloud came with Netflix Hystrix, a well-proven circuit breaker. But as already mentioned above, since the Spring Cloud Greenwich release, it is recommended to replace Netflix Hystrix with Resilience4j. Resilience4j is an open source-based fault tolerance library. It comes with a larger range of fault tolerance mechanisms compared to Netflix Hystrix:
- Circuit breaker is used to prevent a chain of failure reaction if a remote service stops responding.
- Rate limiter is used to limit the number of requests to a service during a specified time period.
- Bulkhead is used to limit the number of concurrent requests to a service.
- Retries are used to handle random errors that might happen from time to time...