categories.system-design Intermediate

Circuit Breaker Pattern: How It Works and Implementation

AI Practice

Circuit Breaker Pattern

The Problem

When Service A calls Service B and B is unresponsive or consistently failing, A accumulates waiting threads and eventually crashes too (cascading failure).

Three Circuit Breaker States

Closed (normal) → failure threshold hit → Open (tripped)
       ↑         ←── reset timeout ──→  ↓
 Half-Open (probe) ← probe succeeds ←───
       ↓ probe fails
       → Open
State Behavior
Closed Normal requests; track failure rate
Open Immediately return error (skip downstream call); give downstream time to recover
Half-Open Allow a few probe requests; decide whether to recover

Implementation Tools

  • Java: Resilience4j, Netflix Hystrix (deprecated)
  • Go: gobreaker
  • Service Mesh: Istio implements this at the sidecar level

Fallback Strategy

When circuit is open, execute a fallback:

  • Return cached stale data
  • Return a default value
  • Return a friendly "service temporarily unavailable" message

Interview bonus: Circuit Breaker + Retry + Timeout + Bulkhead together are called "microservice resilience patterns." Resilience4j provides a complete implementation.

✦ AI Mock Interview

Type your answer and get instant AI feedback

Sign in to use AI scoring

Copyright © 2026 Wood All Rights Reserved · FE Interview Hub