SD Core

Circuit Breaker

Stops calling a failing dependency after threshold failures — fails fast and allows recovery without cascade.

Interview tip Lead with a 30-second definition, then one real system example and name 2–3 designs where Circuit Breaker is non-negotiable.

① What it is (30 seconds)

Stops calling a failing dependency after threshold failures — fails fast and allows recovery without cascade.

② How it works in system design

States: Closed (normal) → Open (reject calls) → Half-open (probe). Count failures in window; open circuit; after cooldown try single request. Prevents thread pile-up on timeouts.
Typical placement
ClientEdge / GatewayCircuitServicesData stores

③ Concrete system design example

Scenario: Payment service calls PSP API. After 5 timeouts in 10s, circuit opens — return graceful error to user, queue retry job instead of hanging 30s per request.

④ Important interview Q&A

QuestionAnswer
Circuit breaker vs retry?Retry helps transient errors; breaker stops hammering dead dependency. Use both with limits.
Fallback when open?Cached quote, degraded mode, or queue for later — never silent wrong data for money.
Half-open probes?One trial request; success closes circuit; failure reopens.

⑤ Seen in these system designs

In interviews, after explaining the concept, say: "This shows up directly in …" and link two designs.

⑥ Revision checklist

  • Three states
  • Failure threshold
  • Fallback defined
  • Half-open probe
  • Metrics on open events
circuit-breakerresiliencemicroservices