1

For resilient distributed system , we have actually 2 patterns , CircuitBreaker and BulkHead .

As circuitBreaker needs to be built at clientSide from where the faulty dependency needs to be called . This will return the default output of faulty one without calling it in case of any outage and avoid calling the faulty dependency , So no new thread will be occupied at that particular point of time .

But in Bulkhead , we have already divided the numberOfThreads on the basis of downstream dependencies and in case of outage , that portion of threads will be blocked , but it'll not be able to use rest of the thread pool. So , the newer threads will be occupied until the proportion is totally occupied .

So , As circuit Breaker , we don't invest threads , but in bulkhead a particular number of threads atleast be invested during the outage .


Q-1. why bulkhead pattern is needed ? Do someone really need to use Bulkhead. If we keep in mind the new thread consumption point during outage . Can someone please trace out some positive points of BulkHead over CircuitBreaker.

Q-2. In this post mentioned that bulkHead needs to be implemented in the service which is being called(faulty service). I really not able to understand , how the faulty dependency/service would be able to divide the threads for itself . In my opinion , the service which is calling the faulty one , should have divided the threads for each downstream dependency including the faulty one. Can someone please clarify .

Q-3. Can someone share some code-references for how they have divided the threads for downstream services while using BulkHead.

Shivanshu
  • 784
  • 1
  • 5
  • 20

1 Answers1

0

R1: Under a high load system (if your timeout limit is relatively high), when a dependency fails or increases the latency, your server can run out of available thread before the circuit breaker opens the circuit.

You could decrease the timeout limit, but at some point and depending on your requirements, it could also be more suitable to limit the number of threads.

Notice that some implementations of CB include by default a Bulkhead pattern.

R2: By "A bulkhead pattern is implemented on the service side" the author means that is implemented an a component that runs in a server but also is a client of other component.(the terms server and client here are relative)

Gabriel Aramburu
  • 2,951
  • 2
  • 16
  • 20