Skip to content
BENIBIX Learn

Circuit Breaker Pattern

Development🏗️ ArchitectureDistributed Systems

Also known as Circuit Breaker

Stop calling a failing service for a while. Then trouble does not spread.

Think of it like

Think of it like the fuse box in a house. When something goes wrong, it cuts the power fast.

Example

Lucy's shop calls a slow reviews service. After 5 failures in a row, the breaker opens. Product pages load without reviews instead of hanging for 30 seconds.

Why it matters

Without it, one slow service can tie up every caller. Then the whole system goes down with it.

Definition

A circuit breaker stops calling a service that keeps failing. That keeps the failure from spreading. It counts errors on calls to that service. After too many, it opens and fails new calls at once, without waiting. After a short rest it lets one test call through. If that works, it closes and normal calls start again.

Common mistake

Showing users an error page when the breaker opens. A good fallback, like hiding the reviews box, keeps the page useful.

Key takeaways

  1. 1
    Count the failures. Then open.
  2. 2
    Fail fast. Do not wait on a dead service.
  3. 3
    Test, then close. One call to check.

Compare