spring-bootmicroservicescircuit-breaker

What is the difference between a circuit breaker and a bulkhead pattern?


Can we use both together in Spring Boot during the development of microservice?


Solution

  • Yes, they can be used together, but it's not always necessary.

    1. As @tom redfern said, circuit breaker is implemented on the caller side. So, if you are sending request to another service, you should wrap those requests into a circuit breaker specific to that service. Keep in mind that every other third party system or service should have it's own circuit breaker. Otherwise, the unavailability of one system will impact the requests that you are sending to the other by opening the circuit breaker.

    More information about circuit breaker can be found here: https://learn.microsoft.com/en-us/azure/architecture/patterns/circuit-breaker

    1. Also, @tom redfern is right again in the case of bulkheading, this is a pattern which is implemented in the service that is called. So, if you are reacting to external requests by spanning other multiple requests or workloads, you should avoid doing all those workloads into a single unit (thread). Instead, separate the workloads into pieces (thread pools) for each request that you have spanned.

    More information about bulkheading can be found here: https://learn.microsoft.com/en-us/azure/architecture/patterns/bulkhead

    Your question was if it's possible to use both these patterns in the same microservice. The answer is: yes, you can and very often the situation implies this.