← Lessons

quiz vs the machine

Gold1420

System Design

The Circuit Breaker Pattern Recap

Stop hammering a failing dependency and fail fast instead.

4 min read · core · beat Gold to climb

The failure spiral

When a dependency slows or fails, callers keep retrying. Threads pile up waiting, the caller itself slows, and the failure spreads. This cascading failure can take down healthy services.

The breaker

A circuit breaker wraps calls to a dependency and tracks failures. It moves between three states:

  • Closed: calls pass through normally.
  • Open: after too many failures it trips, and calls fail fast without hitting the dependency.
  • Half open: after a cooldown it lets a few probe calls through to test recovery.

Why fail fast helps

Failing fast frees threads and returns control quickly, often with a fallback like a cached value. The struggling dependency also gets breathing room to recover.

Key idea

A circuit breaker trips open after repeated failures so calls fail fast with a fallback, stopping cascading failure and letting the dependency recover.

Check yourself

Answer to earn rating on the learn ladder.

1. What does a circuit breaker do in the open state?

2. What is the purpose of the half open state?