Search DistillSys

Find a concept

Type at least two characters to search lessons, designs, papers, and interview prep.

Reliabilityintermediate5 min read

Circuit Breakers

Stop repeated calls to an unhealthy dependency and probe recovery deliberately.

2–5 minute refresher
Mental model

Closed → failure threshold → open → limited probes → closed

30second
refresher
A circuit breaker observes dependency outcomes and temporarily rejects calls when failure indicates continued attempts are harmful. After a pause it admits limited probes before restoring traffic.

What problem does it solve?

Repeated slow or failing calls consume threads, connections, and retry capacity, spreading one dependency failure into caller saturation.

How it works

  1. Record meaningful failures and slow outcomes over a bounded window.
  2. Open when volume and failure thresholds indicate harm.
  3. Return a fast fallback or explicit unavailable result.
  4. After a cooldown, allow a small number of half-open probes.
  5. Close gradually on recovery or reopen immediately when probes fail.
Decision guide

Key trade-offs

ChoiceWhat you gainWhat it costs
Sensitive thresholdFast protectionFalse trips
Long cooldownRecovery breathing roomDelayed restoration
FallbackPreserve user journeyStaleness or reduced functionality
What happens if?

Every application instance probes at once

Synchronized half-open probes can overload a recovering dependency. Add jitter, cap probe concurrency, and coordinate at an appropriate scope.

Where it appears

  • Resilience4j
  • Envoy outlier detection
  • Service clients
  • API gateways
Senior interview modeHow is a circuit breaker different from a retry policy?Show answer
Retries attempt recovery for an individual operation; a breaker uses recent system evidence to stop new attempts temporarily and protect shared resources. They must share one budget.
#circuit breaker#overload#recovery#dependencies