Giter Club home page Giter Club logo

spring-boot-resilience4j-bulkhead's Introduction

Resilience4j Bulkhead: Building Robust Services with Concurrency Limits

For complete understanding of Resilience4j Bulkhead and how we can integrate it inside the Spring Boot application you can checkout our blog.

Blog Link: Resilience4j Bulkhead: Building Robust Services with Concurrency Limits

spring-boot-resilience4j-bulkhead

A simple app demonstrating how we can implement bulkhead pattern using Resilience4j in Spring Boot

App Overview

This is a simple app wherein we are fetching the movie details based on the movie id. The movie details are fetched from external service that is called using the Spring Rest Template. For simplicity, we have created a mock controller which acts as an external service for returning the movie details.

Bulkhead Scenarios

We have created a single controller endpoint which accepts movie id as path parameter and query parameter bulkheadType which accepts predefined set of values to mimic the different bulkhead examples.

Acceptable Values

For Path Parameter - Movie Id

a. 1 - Mock controller returns valid movie information
b. 2 - Mock controller returns valid movie information but with a delay
c. 3 - Mock controller returns HTTP status code 404
d. 4 or any other numeric value - Mock controller returns null which leads to MovieNotFound Exception

For Query Parameter - bulkheadType

Different bulkhead instances are defined inside the application.yml. To mimic different scenarios use:
a. bulkhead-with-max-concurrent-calls: bulkheadWithConcurrentCalls bulkhead instance will be triggered
b. bulkhead-with-max-concurrent-calls-and-max-wait-duration: bulkheadWithConcurrentCallsAndWaitDuration bulkhead instance will be triggered.
c. thread-pool-bulkhead: threadPoolBulkhead bulkhead instance will be triggered.
d. bulkhead-with-max-concurrent-calls-and-fallback: bulkheadWithConcurrentCalls bulkhead instance will be triggered and fallback method logic will be executed in this case.
e. custom-bulkhead: customBulkhead bulkhead instance will be triggered.
f. custom-thread-pool-bulkhead: customThreadPoolBulkhead bulkhead instance will be triggered.

JMeter Test Plan

In order to test different scenarios, run the respective Thread Group inside JMeter. Check the application logs in order to get the better understanding of different bulkhead scenarios.

The JMeter Test Plan is available under the resources folder.
[src > main > resources > jmeter > Resilience4j-bulkhead.jmx]

Testing Bulkhead Examples

a. Import JMeter Test Plan: Begin by importing the JMeter test plan provided in the resources folder into your JMeter application.
b. Enable Respective Thread Group: Based on the scenario you wish to test (e.g., bulkhead-with-max-concurrent-calls or thread-pool-bulkhead), ensure the corresponding thread group is enabled in the test plan. Disable other thread groups to prevent conflicting test scenarios.
c. Review Thread Group Settings: Verify the number of threads or users configured within the enabled thread group. This information can be found in the respective thread group settings.
d. Inspect HTTP Request Configuration: Within the “HTTP Request” sampler of the enabled thread group, review the configured host, port, and endpoint of the application. Confirm that the bulkheadType query parameter is set correctly to define the scenario to test.
e. View Output: After executing the test, examine the output and results in the “View Results Tree” listener of the respective thread group. This listener provides detailed insights into the requests sent, received responses, and any encountered errors or issues during testing.

1. Bulkhead with Max Concurrent Calls

Run "bulkhead-with-max-concurrent-calls" JMeter thread group

2. Bulkhead with Max Concurrent Calls and Max Wait Duration

Run "bulkhead-with-max-concurrent-calls-and-max-wait-duration-calls" JMeter thread group

3. Thread Pool Bulkhead

Run "thread-pool-bulkhead" JMeter thread group

4. Bulkhead with Max Concurrent Calls and Fallback Method

Run "bulkhead-with-max-concurrent-calls-and-fallback" JMeter thread group

5. Custom Bulkhead

Run "custom-bulkhead" JMeter thread group

6. Custom Thread Pool Bulkhead

Run "custom-thread-pool-bulkhead" JMeter thread group

Postman Collection

Additionally, the Postman collection is available under the resources folder containing all the requests including actuator endpoints.
[src > main > resources > postman > Spring-Boot-Resilience4j-Bulkhead.postman_collection.json]

spring-boot-resilience4j-bulkhead's People

Contributors

bootcamptoprod avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.