What is a Circuitbreaker?

Asked

Viewed 86 times

7

I’ve seen some definitions about Circuitbreaker, but I still don’t understand how to use it and I have my doubts.

What is the best case scenario to be applied?

What should be aborted to be fully implemented?

Can be used in any environment?

Which Framework can be used to facilitate use with . NET?

  • I did not know ready so, can be application in Rx, right?

  • Rx ? That’s it. @bigown

  • Reactive programming.

  • @bigown, yes, I’ve been using for that purpose, it focuses on the resiliency of reactive programming.

1 answer

3


I believe that the explanation by Martin Fowler is one of the easiest to understand, with illustrations and examples in code.


Imagine a system that makes several HTTP requests to a webservice remote. For an unknown reason, this webservice starts to get overloaded and HTTP requests take too long and give timeout.

Your system can start blocking important resources by waiting for many requests that will eventually give timeout.

The goal of the Circuit Breaker is to position itself as a layer before the actual feature (the webservice, in this case). In our example, he would be able to identify failures in communication with the webservice (from an external fault count, for example) and cause your query to fail as quickly as possible internally, avoiding waste of resources.

The Circuit Breaker also has the ability to identify when the feature replays, returning to normal flow.


So, answering your questions:

What is the best case scenario to be applied?

Scenarios where failing early results in resource savings. In the above example, a system highly dependent on a webservice remote

What should be aborted to be fully implemented?

I don’t know if I understand the question correctly... But as we have seen above, any costly flow can be aborted.

Can be used in any environment?

Yes. But it is necessary to assess whether the complexity that will be added will compensate at the end.

Which Framework can be used to facilitate use with . NET?

The library Polly offers several policies related to resilience, including Circuit Breaker.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.