Back to list
Lv.2

Circuit Breaker

Circuit Breaker

A mechanism that blocks processing to prevent a failure in one part of a system from spreading to the rest.

In Simple Terms

A circuit breaker is a mechanism that temporarily stops communication with a part of a web service or app where a failure has occurred, preventing the whole system from going down. It's used on websites and services where multiple systems work together. When one server runs into trouble, sending it request after request only adds to its load and can bring the whole system down. By cutting off communication, a circuit breaker protects the whole service from unnecessary load until the problem is resolved.

Behind the Name

It combines "circuit" and "breaker." A circuit breaker was originally an electrical safety device that automatically cuts power when a dangerous current flows through a circuit. IT borrowed the idea: when part of a system fails, communication with it is cut off automatically so the failure doesn't spread further.

Take a Closer Look!

A circuit breaker is a design pattern that prevents a failure in one part of a system from spreading to the rest of it.
It automatically cuts off access to the feature that's failing and returns an error right away, keeping the impact on everything else as small as possible.

For example, when a connected external service or database stops responding, a system would normally keep retrying the connection, and the wait time just keeps growing.
With a circuit breaker in place, it stops trying to connect the moment it detects a problem, which keeps the whole system from slowing down.

Its state is mainly managed through three modes: closed, open, and half-open.
Under normal conditions it's in the closed state, letting communication through, and once errors pass a certain threshold it switches to the open state, blocking communication.
After a set amount of time passes, it moves into the half-open state, tries a small amount of communication, and if recovery is confirmed, it goes back to the closed state.