SlideShare a Scribd company logo
Presented By:
Resilience4j
With
Spring Boot
Shashikant Tanti &
Deepak Kumar
KnolX Etiquettes
Punctuality
Join the session 5 minutes prior
to the session start time. We
start on time and conclude on
time!
Feedback
Make sure to submit a
constructive feedback for all
sessions as it is very helpful for
the presenter.
Silent Mode
Keep your mobile devices in
silent mode, feel free to move
out of session in case you need
to attend an urgent call.
Avoid Disturbance
Avoid unwanted chit chat during
the session.
Our Agenda
01 What is Resilience4j?
02 Why Resilience4j?
03 Resilience4j Modules
04 How to use Resilience4j in your project?
05 Demo
What is Resilience4j?
● Resilience4j is an easy-to-use fault tolerance library inspired by
Netflix Hystrix, but designed for Java 8 and functional
programming.
● In Resilience4j you donʼt have to go all-in, you can pick what
you need.
Why Resilience4j?
● This library is capable of handling the asynchronous calls
● Resilience4j is designed for Java8 and functional programming
● Resilience4j enables the resilience in complex distributed systems
where failure might take place
● Resilience4j is lightweight because it only uses Vavr, which does not
have any other external library dependencies.
How to use Resilience4j in your projects?
You can simply use the following dependency in your maven project and get started
with the Resilience4j
To add the Resilience4j dependency to your project, you need to add the following
dependency to your pom.xml file:
<dependency>
<groupId>io.github.resilience4j</groupId>
<artifactId>resilience4j-spring-boot2</artifactId>
<version>1.3.3</version>
</dependency>
Resilience4j Module
● Circuit Breaker
● Retry
● Rate Limiter
● BulkHead
● Time Limiter
● Cache
Circuit Breaker Module
● The circuit breaker is essentially a pattern that helps to prevent
cascading failures in a system.
● The circuit breaker pattern allows you to build a fault-tolerant
and resilient system that can survive gracefully when key services
are either unavailable or have high latency.
● Circuit breaker pattern is generally used in microservices
architecture where there are multiple services involved but it can
be used otherwise as well.
Circuit Breaker Module
The circuit breaker has the following 3 states
Closed – Closed is when everything is normal, in the beginning,
it will be in the closed state and if failures exceed the
threshold value decided at the time of creating circuit breaker,
the circuit will trip and go into an open state.
Open – Open is the state when the calls start to fail without any
latency i.e calls will start to fail fast without even executing the
function calls.
Circuit Breaker Module
Half-open – In half-open state what will happen is, the very first
call will not fail fast and all other calls will fail fast just as in the
open state. If the first call succeeds then the circuit will go
inthe closed state again and otherwise, it will go into the open
state again waiting for the reset timeout.
Circuit Breaker
BulkHead Pattern
The BulkHead Pattern is a type of application design that is
tolerant of failure. In a bulkhead architecture, elements of an
application isolated into pools so that if one fails, the other will
continue of function.
BulkHead Implementation framework
1. Hystrix
2. Resilience4j
BulkHead Pattern
When to use BulkHead Pattern
1. Apply the bulkhead pattern whenever you want to scale a
service independent of other services.
2. Isolate resources used to consume a set of backed services,
especially if the application can provide some level of
functionality even when one of the service is not responding.
3. Apply the bulkhead pattern to fault isolate components of
varying risk or availability requirements.
4. Protect the application from cascading failure.
Retry Module
● There can be scenarios when there are intermittent network
connectivity errors causing your service to be unavailable.
● These issues are generally self-correcting and if you retry the
operation after a small delay its most probably going to succeed.
● Retry pattern help to resolve transient failures in distributed
architecture by automatically hit the target resource again after
some specific time.
user-service catalog-service
Resilience4j:
retry:
instances:
userService:
maxRetryAttempts: 4
waitDuration: 5s
Service A Service B
Failure response
Retry
1
2
3
4
The faults are expected to be short lived, and repeating request
that failed previously could succeed on a subsequent attempt.
● Calling an HTTP service from another REST endpoint.
● Calling a web service.
● No or slow responses due to a large number of requests towards
the resource(database or service).
When to use Retry
1. Setting a limit on the amount of time we are willing to wait for an
operation to complete is called time limiting.
2. If the operation does not complete within the time specified, we
want to notified about it with a timeout error.
Time Limiter
Resilience4jʼs TimeLimiter can be used to set limits (timeouts) on
asynchronous operations implemented with completableFuture.
Configuration
timeoutDuration:2s
cancelRunningFuture:true
Resilience4j Time Limiter
Rate limiter pattern helps us to make services highly available
just by limiting the number of calls we could process in a
specific window.
Rate limiting specified in terms of
1. Requests per second(rpc)
2. Requests per minute(rpm)
3. Requests per hour(rph)
Rate Limiter Pattern
Resilience4j-ratelimiter
● https://resilience4j.readme.io/docs/getting-started
● https://github.com/resilience4j/resilience4j
●
https://blog.knoldus.com/circuit-breaker-with-resilience4j/
● https://blog.knoldus.com/retry-with-resilience4j/
References
Thank You !
Thank You
!
Demo
Do remember to submit
feedback!
Thank You !

More Related Content

PDF
Introduction to Resilience4j
PPTX
KEY
Concurrent Programming Using the Disruptor
PDF
Testing with JUnit 5 and Spring
PDF
An Introduction of Node Package Manager (NPM)
PPTX
Spring boot Introduction
PPTX
Pentesting ReST API
Introduction to Resilience4j
Concurrent Programming Using the Disruptor
Testing with JUnit 5 and Spring
An Introduction of Node Package Manager (NPM)
Spring boot Introduction
Pentesting ReST API

What's hot (20)

PDF
Spring Security
PDF
Secure coding presentation Oct 3 2020
PDF
Spring Framework - AOP
PDF
Understanding Reactive Programming
PDF
Introduction to java (revised)
PPTX
JSON: The Basics
PPTX
Introduction to Node.js
PPTX
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
PDF
An Introduction to Test Driven Development
PDF
REST API Basics
PPTX
PPTX
Project Reactor By Example
PPTX
Introduction to java
PDF
Hibernate Presentation
PDF
Networking in Java with NIO and Netty
PPTX
Reactive programming by spring webflux - DN Scrum Breakfast - Nov 2018
PDF
Api security-testing
PPTX
Understanding REST APIs in 5 Simple Steps
PDF
Project Reactor Now and Tomorrow
Spring Security
Secure coding presentation Oct 3 2020
Spring Framework - AOP
Understanding Reactive Programming
Introduction to java (revised)
JSON: The Basics
Introduction to Node.js
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
An Introduction to Test Driven Development
REST API Basics
Project Reactor By Example
Introduction to java
Hibernate Presentation
Networking in Java with NIO and Netty
Reactive programming by spring webflux - DN Scrum Breakfast - Nov 2018
Api security-testing
Understanding REST APIs in 5 Simple Steps
Project Reactor Now and Tomorrow
Ad

Similar to Resilience4j with Spring Boot (20)

PPTX
Circuit Breaker.pptx
PDF
Resilience4J
PDF
Circuit breakers - Using Spring-Boot + Hystrix + Dashboard + Retry
PPTX
Demystifying the use of circuit breakers with MuleSoft
PPTX
Building Cloud Ready Apps
PPTX
DoT NeT resiliency framework - Polly.pptx
PPTX
Multi threading
PDF
Multithreading in Scala
PPTX
Stability Patterns for Microservices
PDF
[WSO2Con EU 2017] Resilience Patterns with Ballerina
PDF
Droidcon Spain 2016 - The Pragmatic Android Programmer: from hype to reality
PDF
PyCon Canada 2019 - Introduction to Asynchronous Programming
PPTX
Advanced python
PPTX
Remote core locking-Andrea Lombardo
PDF
Latency Control And Supervision In Resilience Design Patterns
PPTX
Microservices Resilient Engineering - Java meetup.pptx
PPTX
Connection Resiliency and Command Interception in Entity Framework
PPTX
Synchronization problem with threads
PDF
Resilience Planning & How the Empire Strikes Back
PPTX
Performance tuning Grails applications SpringOne 2GX 2014
Circuit Breaker.pptx
Resilience4J
Circuit breakers - Using Spring-Boot + Hystrix + Dashboard + Retry
Demystifying the use of circuit breakers with MuleSoft
Building Cloud Ready Apps
DoT NeT resiliency framework - Polly.pptx
Multi threading
Multithreading in Scala
Stability Patterns for Microservices
[WSO2Con EU 2017] Resilience Patterns with Ballerina
Droidcon Spain 2016 - The Pragmatic Android Programmer: from hype to reality
PyCon Canada 2019 - Introduction to Asynchronous Programming
Advanced python
Remote core locking-Andrea Lombardo
Latency Control And Supervision In Resilience Design Patterns
Microservices Resilient Engineering - Java meetup.pptx
Connection Resiliency and Command Interception in Entity Framework
Synchronization problem with threads
Resilience Planning & How the Empire Strikes Back
Performance tuning Grails applications SpringOne 2GX 2014
Ad

More from Knoldus Inc. (20)

PPTX
Angular Hydration Presentation (FrontEnd)
PPTX
Optimizing Test Execution: Heuristic Algorithm for Self-Healing
PPTX
Self-Healing Test Automation Framework - Healenium
PPTX
Kanban Metrics Presentation (Project Management)
PPTX
Java 17 features and implementation.pptx
PPTX
Chaos Mesh Introducing Chaos in Kubernetes
PPTX
GraalVM - A Step Ahead of JVM Presentation
PPTX
Nomad by HashiCorp Presentation (DevOps)
PPTX
Nomad by HashiCorp Presentation (DevOps)
PPTX
DAPR - Distributed Application Runtime Presentation
PPTX
Introduction to Azure Virtual WAN Presentation
PPTX
Introduction to Argo Rollouts Presentation
PPTX
Intro to Azure Container App Presentation
PPTX
Insights Unveiled Test Reporting and Observability Excellence
PPTX
Introduction to Splunk Presentation (DevOps)
PPTX
Code Camp - Data Profiling and Quality Analysis Framework
PPTX
AWS: Messaging Services in AWS Presentation
PPTX
Amazon Cognito: A Primer on Authentication and Authorization
PPTX
ZIO Http A Functional Approach to Scalable and Type-Safe Web Development
PPTX
Managing State & HTTP Requests In Ionic.
Angular Hydration Presentation (FrontEnd)
Optimizing Test Execution: Heuristic Algorithm for Self-Healing
Self-Healing Test Automation Framework - Healenium
Kanban Metrics Presentation (Project Management)
Java 17 features and implementation.pptx
Chaos Mesh Introducing Chaos in Kubernetes
GraalVM - A Step Ahead of JVM Presentation
Nomad by HashiCorp Presentation (DevOps)
Nomad by HashiCorp Presentation (DevOps)
DAPR - Distributed Application Runtime Presentation
Introduction to Azure Virtual WAN Presentation
Introduction to Argo Rollouts Presentation
Intro to Azure Container App Presentation
Insights Unveiled Test Reporting and Observability Excellence
Introduction to Splunk Presentation (DevOps)
Code Camp - Data Profiling and Quality Analysis Framework
AWS: Messaging Services in AWS Presentation
Amazon Cognito: A Primer on Authentication and Authorization
ZIO Http A Functional Approach to Scalable and Type-Safe Web Development
Managing State & HTTP Requests In Ionic.

Recently uploaded (20)

DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Empathic Computing: Creating Shared Understanding
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Spectral efficient network and resource selection model in 5G networks
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Cloud computing and distributed systems.
PPT
Teaching material agriculture food technology
PPTX
Spectroscopy.pptx food analysis technology
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Machine learning based COVID-19 study performance prediction
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
The AUB Centre for AI in Media Proposal.docx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Unlocking AI with Model Context Protocol (MCP)
Empathic Computing: Creating Shared Understanding
Encapsulation_ Review paper, used for researhc scholars
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Reach Out and Touch Someone: Haptics and Empathic Computing
Spectral efficient network and resource selection model in 5G networks
“AI and Expert System Decision Support & Business Intelligence Systems”
Cloud computing and distributed systems.
Teaching material agriculture food technology
Spectroscopy.pptx food analysis technology
Agricultural_Statistics_at_a_Glance_2022_0.pdf
MYSQL Presentation for SQL database connectivity
Per capita expenditure prediction using model stacking based on satellite ima...
Chapter 3 Spatial Domain Image Processing.pdf
Machine learning based COVID-19 study performance prediction
Diabetes mellitus diagnosis method based random forest with bat algorithm

Resilience4j with Spring Boot

  • 2. KnolX Etiquettes Punctuality Join the session 5 minutes prior to the session start time. We start on time and conclude on time! Feedback Make sure to submit a constructive feedback for all sessions as it is very helpful for the presenter. Silent Mode Keep your mobile devices in silent mode, feel free to move out of session in case you need to attend an urgent call. Avoid Disturbance Avoid unwanted chit chat during the session.
  • 3. Our Agenda 01 What is Resilience4j? 02 Why Resilience4j? 03 Resilience4j Modules 04 How to use Resilience4j in your project? 05 Demo
  • 4. What is Resilience4j? ● Resilience4j is an easy-to-use fault tolerance library inspired by Netflix Hystrix, but designed for Java 8 and functional programming. ● In Resilience4j you donʼt have to go all-in, you can pick what you need.
  • 5. Why Resilience4j? ● This library is capable of handling the asynchronous calls ● Resilience4j is designed for Java8 and functional programming ● Resilience4j enables the resilience in complex distributed systems where failure might take place ● Resilience4j is lightweight because it only uses Vavr, which does not have any other external library dependencies.
  • 6. How to use Resilience4j in your projects? You can simply use the following dependency in your maven project and get started with the Resilience4j To add the Resilience4j dependency to your project, you need to add the following dependency to your pom.xml file: <dependency> <groupId>io.github.resilience4j</groupId> <artifactId>resilience4j-spring-boot2</artifactId> <version>1.3.3</version> </dependency>
  • 7. Resilience4j Module ● Circuit Breaker ● Retry ● Rate Limiter ● BulkHead ● Time Limiter ● Cache
  • 8. Circuit Breaker Module ● The circuit breaker is essentially a pattern that helps to prevent cascading failures in a system. ● The circuit breaker pattern allows you to build a fault-tolerant and resilient system that can survive gracefully when key services are either unavailable or have high latency. ● Circuit breaker pattern is generally used in microservices architecture where there are multiple services involved but it can be used otherwise as well.
  • 9. Circuit Breaker Module The circuit breaker has the following 3 states Closed – Closed is when everything is normal, in the beginning, it will be in the closed state and if failures exceed the threshold value decided at the time of creating circuit breaker, the circuit will trip and go into an open state. Open – Open is the state when the calls start to fail without any latency i.e calls will start to fail fast without even executing the function calls.
  • 10. Circuit Breaker Module Half-open – In half-open state what will happen is, the very first call will not fail fast and all other calls will fail fast just as in the open state. If the first call succeeds then the circuit will go inthe closed state again and otherwise, it will go into the open state again waiting for the reset timeout.
  • 12. BulkHead Pattern The BulkHead Pattern is a type of application design that is tolerant of failure. In a bulkhead architecture, elements of an application isolated into pools so that if one fails, the other will continue of function. BulkHead Implementation framework 1. Hystrix 2. Resilience4j
  • 14. When to use BulkHead Pattern 1. Apply the bulkhead pattern whenever you want to scale a service independent of other services. 2. Isolate resources used to consume a set of backed services, especially if the application can provide some level of functionality even when one of the service is not responding. 3. Apply the bulkhead pattern to fault isolate components of varying risk or availability requirements. 4. Protect the application from cascading failure.
  • 15. Retry Module ● There can be scenarios when there are intermittent network connectivity errors causing your service to be unavailable. ● These issues are generally self-correcting and if you retry the operation after a small delay its most probably going to succeed. ● Retry pattern help to resolve transient failures in distributed architecture by automatically hit the target resource again after some specific time.
  • 17. The faults are expected to be short lived, and repeating request that failed previously could succeed on a subsequent attempt. ● Calling an HTTP service from another REST endpoint. ● Calling a web service. ● No or slow responses due to a large number of requests towards the resource(database or service). When to use Retry
  • 18. 1. Setting a limit on the amount of time we are willing to wait for an operation to complete is called time limiting. 2. If the operation does not complete within the time specified, we want to notified about it with a timeout error. Time Limiter
  • 19. Resilience4jʼs TimeLimiter can be used to set limits (timeouts) on asynchronous operations implemented with completableFuture. Configuration timeoutDuration:2s cancelRunningFuture:true Resilience4j Time Limiter
  • 20. Rate limiter pattern helps us to make services highly available just by limiting the number of calls we could process in a specific window. Rate limiting specified in terms of 1. Requests per second(rpc) 2. Requests per minute(rpm) 3. Requests per hour(rph) Rate Limiter Pattern
  • 23. Thank You ! Thank You ! Demo
  • 24. Do remember to submit feedback!