Circuit Breaker Pattern

Let's learn about how circuit breakers help keep our services available.

Introduction

Circuit breakers are a staple in every modern house. The electricity in our houses comes through the main grid and flows through the circuit breakers. There’s a chance that the grid might behave abnormally once in a while, causing an electrical surge that the wiring of our house might not be able to tolerate. Circuit breakers help us prevent the above scenario, protecting our wiring and appliances by switching them off if they detect an abnormally high amount of power.

The circuit breaker pattern that’s often used in API design functions is quite similar to electrical circuit breakers. It acts as a protective layer of our APIs, preventing them from receiving more requests than they can handle. It’s an effective method for increasing the availability of our services by detecting and potentially preventing cascading failures. It allows us to create a fault-tolerant system that can survive when key services are unavailable.

Level up your interview prep. Join Educative to access 80+ hands-on prep courses.