← Home
🏗Crack System Design with DSA AnimatorSystem DesignNEW
🏗 System Design›Reliability & Scalability

🛡️Circuit Breaker / Retry / Bulkhead

Use complementary resilience patterns instead of one-size-fits-all retries.

📌 Key IdeaRetries recover transient failures, circuit breakers fail fast on sustained outages, and bulkheads isolate resources so one bad dependency cannot exhaust the whole service.
🧩

Problem it solves

  • A failing downstream dependency can cascade and take down otherwise healthy services.
  • Blind retries during outages often increase load and make recovery slower.
  • Circuit breaker + retry + bulkhead split recovery, fail-fast, and isolation concerns cleanly.
✨

Why It Matters

  • Resilience patterns prevent one dependency outage from crashing the whole service.
  • Correct policies protect latency SLOs during partial failures and traffic spikes.
  • They convert random failure behavior into controlled, observable degradation.
🖼

Visual

🛡️ Resilience trio in call path
Request -> Retry policy -> Circuit Breaker -> Bulkhead-isolated dependency

Retry      : handles transient failures
Breaker    : stops hammering unhealthy dependency
Bulkhead   : limits blast radius by resource partitioning
✅

When to Use

  • Networked microservice calls with dependency failures.
  • Critical APIs where cascading failures must be contained.
  • Systems with variable downstream latency and intermittent outages.
🚫

When NOT to Use

  • Blind retries on non-idempotent operations.
  • Huge retry counts without jitter/backoff (retry storms).
💻

Code Variations

Resilience4j sketchjava
Supplier<Response> guarded = Decorators.ofSupplier(() -> client.call())
    .withRetry(retry)
    .withCircuitBreaker(circuitBreaker)
    .withBulkhead(bulkhead)
    .decorate();
Order and policy tuning matter; observe rejection/timeout metrics.
📊

Pattern purpose matrix

AspectRetryCircuit BreakerBulkhead
Primary problem solvedTransient error recoveryFail-fast during sustained failureResource isolation / blast-radius control
Main riskAmplified load under outageToo aggressive open thresholdsOver-partitioning resources
Must pair withBackoff + jitter + idempotencyHealth probes/half-open tuningCapacity planning + queueing policy
🎤

Interview Q&A

🧾

Quick Cheat Sheet

RetryTransient failures only; exponential backoff + jitter.
BreakerOpen on failure threshold; half-open probes for recovery.
BulkheadSeparate pools/queues per dependency path.
🔗

Related Topics