Fail Fast & Self Healing using Circuit Breaker

What is Circuit Breaker?

Circuit Breaker is a pattern to monitor the failures and it keeps the count of failure, after reaching the threshold of failure. it stops sending requests to the external server till timeout.

State of the Circuit Breaker

Circuit Breaker has three states:

Closed: It is a normal state. Every request going through the services.

Open: When shit started, If External server is started to failing the requests then the circuit breaker comes in open state once the failure threshold reached. No requests go to the external services. Simply fail fast ☺

Half-Open: After the timeout, the Circuit breaker went to the half-open state, now requests go to the services and if any requests failed then still state moved to open state otherwise reset to the closed state. Simply automatic healing ☺

How it benefits?

It prevents cascading failures and keeps the system responsive.

  • We can set a default response until Circuit Breaker is in open state.
  • Other functionality & API should work.
  • If we know the other system is down then no need to send requests & wait for a response.
  • Automatically check the system status in the half-open state.


Further Reading:

  1. Martin Flower blog:
  2. Netflix blog:
  3. Netflix Open Source Hystrix:

Leave a Reply

Your email address will not be published. Required fields are marked *