Retries with resilience4j and how to check in your Real World Environment
Blog post from Steadybit
Resilience4j is a framework that integrates seamlessly with Spring Boot to enhance the resilience of applications by implementing fault tolerance mechanisms, such as retries, which are crucial for maintaining service availability during backend failures. In a practical example involving an online shopping demo, Resilience4j is utilized to implement a retry mechanism for a Gateway microservice that fetches product data from three other microservices using synchronous REST calls. By annotating the service methods with Resilience4j's @Retry, the application can handle exceptions by retrying the failed calls, and if unsuccessful, it invokes a fallback method, thus preventing the system from returning error responses. An experiment conducted under load conditions demonstrated that, with the retry mechanism applied, the gateway endpoint managed to return successful responses (HTTP 200) despite backend failures, albeit with increased response times due to the retry wait duration. This highlights the importance of testing the system's behavior in integrated environments to ensure performance isn't adversely affected. The post concludes by suggesting the use of a CircuitBreaker to further manage potential issues arising from increased load due to retries, which will be explored in a subsequent post.