Vikas Kumar
Vikas's blog

Vikas's blog

Fail Fast & Self Healing Using Circuit Breaker

Vikas Kumar's photo
Vikas Kumar
·Jun 1, 2022·

1 min read

Play this article

Table of contents

  • What is Circuit Breaker?
  • State of the Circuit Breaker
  • How does it benefit?
  • Implementations:
  • Further Reading:

What is Circuit Breaker?

Circuit Breaker is a pattern to monitor the failures and it keeps the count of failures, 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 goes through the services.

Open: When shit started, If the External server started to fail the requests then the circuit breaker came in the open state once the failure threshold reached. No requests go to 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 they still state moved to the open state otherwise reset to the closed state. Simply automatic healing.

How does it benefit?

It prevents cascading failures and keeps the system responsive.

We can set a default response until Circuit Breaker is in the 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:

Share this