System Design Academy

Saving…

Lesson 4 of 10 in Module 50 of 54 lessons complete

Circuit Breakers & Bulkheads

Module 5, lesson 4Concept12 min

Definition

Circuit breaker

In plain English
A circuit breaker stops calling a failing dependency for a while after too many errors, failing fast instead.
Think of it like
It is like a household fuse that trips to stop damage, then gets reset.

Bulkhead

In plain English
A bulkhead gives each kind of work its own limited pool of resources so one slow part can't use them all.
Think of it like
It is like a ship's watertight compartments that keep one leak from sinking the whole ship.

Why it exists

Payments stop responding, but every checkout waits ten seconds. Waiting work consumes the workers needed by healthy features.

Timeouts limit each wait. You also need to stop calling a dependency that keeps failing and reserve capacity for critical work.

How it works

Closed, open and half-open

In plain English
A breaker is closed when calls flow, open when calls are blocked, and half-open when a few test calls check for recovery.
Think of it like
Like a shop door that is open, locked, or opened a crack to peek outside.

Fallback

In plain English
A fallback is a simpler answer used when the real one isn't available.
Think of it like
Like a cached weather forecast when the live one fails.

The breaker starts closed, opens after failures, then allows half-open test calls that either close or reopen it.

The breaker probes recovery before restoring normal traffic.

The breaker starts closed, opens after failures, then allows half-open test calls that either close or reopen it.

  1. Measure failures

    Count recent errors and require enough calls before using a percentage threshold.

  2. Open

    Stop calling the dependency during a cool-down period.

  3. Respond

    Return a useful fallback or a clear temporary error.

  4. Probe

    Allow a few half-open test calls, then close on success or reopen on failure.

Requests go to separate pools with twenty door-unlock workers and five analytics workers.

Bulkheads reserve capacity for separate kinds of work.

Requests go to separate pools with twenty door-unlock workers and five analytics workers.

Examples

Fail fast during payment trouble

Payments fail on half the calls in a ten-second window, so the breaker opens.

Require a minimum sample, such as 20 calls, before applying the 50% threshold. One failed call should not establish a reliable percentage.

Checkout reaches an open breaker, confirms an existing seat hold, and returns a temporary payment error.

A fast error should tell the buyer what happens next.

Checkout reaches an open breaker, confirms an existing seat hold, and returns a temporary payment error.

Say seats are held for ten minutes only after the booking system confirms that hold. A fallback cannot invent a reservation.

The insight

Failing fast protects users and server capacity.

Trade-offs

Pros

  • Fails quickly during repeated errors.
  • Lets dependencies recover.
  • Contains resource exhaustion.

Cons

  • Thresholds need tuning.
  • Brief failures can trip a breaker.
  • Fallbacks may return incomplete data.

Use when

  • Remote calls can fail or slow down.
  • Critical work shares resources with optional work.

Avoid when

  • An in-process call needs only error handling.
  • A fallback would claim an action happened when it did not.

Quick check

In which breaker state are calls blocked immediately?
Slow analytics calls start blocking door unlocks. Which pattern isolates them?

Takeaways

  • Circuit breakers fail fast when a dependency is down.
  • Bulkheads stop one slow part taking every resource.
  • Pair both with timeouts and fallbacks.

Try the quick check above whenever you feel ready.

Previous: Rate-Limiting Algorithms