top of page

Resiliance4J

  • Writer: Anand Nerurkar
    Anand Nerurkar
  • Mar 22, 2024
  • 1 min read

Updated: Jun 11, 2024

Resilience4j is a lightweight fault tolerance library designed for functional programming. Resilience4j provides higher-order functions (decorators) to enhance any functional interface, lambda expression or method reference with a Circuit Breaker, Rate Limiter, Retry or Bulkhead. You can stack more than one decorator on any functional interface, lambda expression or method reference. The advantage is that you have the choice to select the decorators you need and nothing else.


Resilience4j 2 requires Java 17.


Resiliance4J pattern

==


In API Gateway, the burst limit represents the target maximum number of concurrent request submissions that API Gateway will fulfill

The burst limit defines the number of requests your API can handle concurrently. The rate limit defines the number of allowed requests per second. This is an implementation of the Token bucket implementation.

Let us assume below scenario


Service B is down or very slow to respond, in this case we can make use of resilance4j library

and implement below options

  1. Retry

  2. CircuitBreaker

  3. Rate Limiter

  4. BulkHead Circuit Breaker


code snippet- happy path

need to add resilance4j,aop,actuator dependency in pom.xml for serviceA,B

serviceB;


ServiceA:


Assume service A,B are working fine , in this case output would be

serviceB is called by ServiceA


Assume ServiceB is down, this is where it will cascade failure to service A , in such scenario, we will make use of ckt breaker pattern as below


serviceA:


enable management endpoit as below

application.yml

==


enable cktbreaker

==


we have defined 10 request in a given time, 50 % threshold- minmum 5 request to be failed, then cktbreaer fallback will kick in.


  1. Retry



Rate Limiter



BulkHead






 
 
 

Recent Posts

See All
RFP PRE/POST-PROPOSAL SUBMISSION FLOW

🏆 1. The 5 Pillars to Win a Large Strategic Deal 1. Understand the Client Better Than They Do 👉 Don’t just read RFP — decode it What is their real problem ? What is driving this deal? (compliance, c

 
 
 
DIGITAL LENDING RFP Solution

🎯 RFP Proposal SOLUTION PRESENTATION – DIGITAL LENDING (WITH COLOR-CODED ARCHITECTURE) 1️⃣ Opening “Thank you for the opportunity. I’ll walk you through our approach to building a next-generation dig

 
 
 

Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating
  • Facebook
  • Twitter
  • LinkedIn

©2024 by AeeroTech. Proudly created with Wix.com

bottom of page