Friday, June 2, 2023

Circuit breaker pattern algorithm

This post is about trying to implement the circuit breaker pattern in your program. Analgous to the electrical circuit breaker in the house,the circuit breaker can be built and customized to improve system resilience.

Basic steps -

1. Count the error API's say for a speicific API and store it.
2. Once the count exceeds the limit say 10, move the client system to the Half - open state and start the timer.
3. Set the timer to about say 15 seconds.
4. After the timer expires, try the call(s) again slowly.
5. If the calls fail, move the system to the Open state.
6. Otherwise, the specific API can be put into Closed state again.


State definition -

Open - Client is not sending any calls (may be specific API).
Half - Open - System  in probe mode after failures to check resilience.
Closed - System performing as normal and no issues from the server.

No comments:

Post a Comment

Browser background color or monitor brightness

Have you been in a situation where you are almost sitting the whole day in front of your browser and going through a document and find that ...