Resilience Patterns
1. Executive Summary
Resilience patterns are structural defenses against partial failure in distributed systems. When one service slows or fails, uncontrolled retry storms and cascading overload can convert a localized fault into a system-wide outage. Patterns—timeouts, retries with backoff, circuit breakers, bulkheads, load shedding, and graceful degradation—bound blast radius and preserve liveness for critical paths.
Resilience is not "add a library." It requires explicit SLO budgets, failure budgets, idempotent endpoints, observability of saturation, and organizational policies (when to fail open vs closed). Principal architects design these as platform defaults with escape hatches, not as per-team afterthoughts.
This chapter covers mechanism, guarantees, tuning tradeoffs, anti-patterns (retry storms, retry without jitter), integration with service mesh, and interview-level failure reasoning.
2. Why This Topic Matters
Microservice interviews probe whether candidates understand that failure is normal:
- A dependency at 99.9% availability contributes ~43 minutes/month downtime—your service cannot pretend it is always up.
- Cascading failure from thread pool exhaustion is a classic principal-level scenario.
- Circuit breaker state transitions and half-open probing require precise explanation.
- Idempotency and retries are inseparable—unsafe retries corrupt data.
Weak answers list pattern names without discussing when they hurt (circuit breakers causing false opens, hedging doubling load).
3. Problems Being Solved
| Problem | Resilience pattern |
|---|---|
| Hung requests blocking threads | Timeouts on client and server |
| Transient network blips | Retry with exponential backoff + jitter |
| Failing dependency overload | Circuit breaker opens; fail fast |
| One tenant exhausts pool | Bulkhead isolation |
| Traffic spike exceeds capacity | Load shedding, rate limiting, queue caps |
| Non-critical feature blocks core path | Graceful degradation, fallbacks |
| Thundering herd on recovery | Jittered backoff, gradual ramp |
Patterns do not fix: incorrect consistency assumptions, missing idempotency, or under-provisioned capacity without autoscaling limits.
4. Assumptions and System Model
| Assumption | Implication |
|---|---|
| Partial failure is common | Design every outbound call to fail |
| Latency has tails | Percentile SLOs; timeouts below client deadline |
| Retries amplify load | Cap retry budget; coordinate with server rate limits |
| Not all failures are retryable | 4xx vs 5xx; business validation errors |
| Cascading failure is a liveness threat | Shed load before total collapse |
Client model: Each outbound call has timeout T, retry policy R, breaker state B, and bulkhead quota Q. Server exposes health that reflects dependency health (deep health checks) vs liveness (shallow).
5. Essential Terminology
| Term | Definition |
|---|---|
| Timeout | Maximum wait before abandoning a call |
| Retry | Repeat failed call subject to policy |
| Exponential backoff | Increasing delay between retries |
| Jitter | Randomized delay to desynchronize retries |
| Circuit breaker | Fail-fast after error threshold; periodic half-open probe |
| Bulkhead | Resource pool isolation limiting cross-coupling |
| Load shedding | Reject excess requests to protect survivors |
| Graceful degradation | Reduced functionality vs total failure |
| Hedging | Send duplicate request if first slow—doubles load |
| Fail open / fail closed | Degrade permissively vs deny when dependency down |
6. Core Mechanism
Circuit breaker state machine
Figure 1: Closed allows traffic; Open fails fast; HalfOpen tests recovery with limited probes.
Bulkhead isolation
Figure 2: Bulkheads prevent one slow dependency from exhausting all worker threads.
Retry with backoff and jitter
Figure 3: Bounded retries with increasing delay; jitter prevents synchronized retry storms.
Timeout budget chaining
For request path A → B → C, total deadline must fit:
| Hop | Budget | Cumulative |
|---|---|---|
| A processing | 50ms | 50ms |
| A → B call | 200ms | 250ms |
| B → C call | 150ms | 400ms |
| Client deadline | 500ms | margin 100ms |
Child timeouts must be shorter than parent remaining budget.
7. Step-by-Step Walkthrough
Scenario: Order service calls Payment service during checkout spike.
| Step | Event | Resilience response |
|---|---|---|
| 1 | Payment latency p99 rises 200ms → 2s | Client timeout at 800ms triggers |
| 2 | Errors exceed 50% in 10s window | Circuit breaker opens |
| 3 | Open state | Fail fast; queue checkout for async retry |
| 4 | 30s cooldown | Half-open sends 5 probe requests |
| 5 | Probes succeed | Breaker closes; gradual traffic restore |
| 6 | Retry policy | Max 3 attempts, exponential backoff, idempotency key |
Idempotency: Idempotency-Key: uuid header ensures duplicate retries do not double-charge.
Retry budget calculation (platform default example):
For a client making N concurrent requests with R max retries each, worst-case load multiplier on a failing dependency is approximately N × (R + 1). At 1000 RPS with 3 retries, a failing payment service could see 4000 RPS—enough to prevent recovery (metastable failure per OSDI research).
Platform defaults should include:
| Parameter | Suggested starting point | Tune from |
|---|---|---|
| Max retries | 2–3 | Error budget impact |
| Base backoff | 100ms | Dependency recovery time |
| Max backoff | 2s | Client SLA |
| Jitter | Full jitter (AWS pattern) | Retry storm metrics |
| Per-dependency retry budget | 10% of normal QPS cap | Load test |
Graceful degradation tiers (document in runbooks):
| Tier | Feature | Degradation behavior |
|---|---|---|
| 0 | Checkout, auth | Fail closed; no silent bypass |
| 1 | Recommendations | Empty list; cached popular items |
| 2 | Social proof ("X bought this") | Hide widget |
| 3 | Analytics beacons | Drop silently; queue locally |
8. Invariants and Guarantees
| Property | Type | Statement |
|---|---|---|
| Fail fast when open | Liveness | Breaker open rejects without waiting full timeout |
| No unbounded retries | Safety | Retry cap prevents infinite amplification |
| Idempotent retries | Safety | Duplicate attempts safe for mutating ops |
| Bulkhead isolation | Liveness | Pool exhaustion localized to bulkhead |
| Perfect resilience | Not guaranteed | Total overload or shared infrastructure still fails |
9. Failure Scenarios
Scenario 1: Retry storm
Setup: 1000 clients retry immediately on 503 without backoff.
Effect: Payment service never recovers—metastable failure.
Mitigation: Exponential backoff + jitter; server Retry-After; client retry budget.
Scenario 2: Circuit breaker flapping
Setup: Threshold too sensitive; half-open allows full traffic immediately.
Effect: Oscillation between open/closed; erratic error rates.
Mitigation: Sliding window; minimum open duration; limited half-open concurrency.
Scenario 3: Timeout mismatch
Setup: Client timeout 30s; load balancer idle 60s; threads tied up.
Effect: Thread pool exhaustion; cascading latency.
Mitigation: End-to-end deadline propagation (gRPC deadline, context cancellation).
Scenario 4: Unsafe retry on POST
Setup: Payment charge retried after timeout; first request actually succeeded.
Effect: Double charge.
Mitigation: Idempotency keys; deduplication store; at-most-once business semantics.
Scenario 5: Hedging under load
Setup: Hedged requests on all slow reads during incident.
Effect: 2× load on already struggling dependency.
Mitigation: Hedging only below p99 threshold; cap hedge rate.
Scenario 6: Shared breaker state missing
Setup: 50 pod replicas each maintain independent circuit breaker; 10% see errors, 90% do not—breaker never opens cluster-wide.
Effect: Continued load on failing dependency from majority of pods.
Mitigation: Adaptive algorithms, shared state (Redis), or outlier detection at load balancer/mesh layer.
10. Performance Characteristics
| Pattern | Latency impact | Load impact |
|---|---|---|
| Timeout | Caps tail wait | Frees resources faster |
| Retry | Increases tail on success path | Multiplies load on failure |
| Circuit breaker | Near-zero when open | Reduces load on failing dep |
| Bulkhead | Queue wait if pool full | Caps concurrent dep load |
| Hedging | Reduces tail if lucky | Up to 2× requests |
| Load shedding | Fast reject | Protects capacity |
Tune with load tests reproducing dependency failure—not happy path only.
11. Scalability Limits
- Circuit breaker state is per client instance—cluster-wide view needs shared state or adaptive algorithms.
- Bulkhead pools require capacity planning—too small → false rejects; too large → no isolation.
- Retry budgets must scale with client count—global rate limits on server side essential.
- Service mesh adds hop latency (~1–3ms)—verify against SLO budget.
12. Operational Considerations
- Dashboards: breaker state transitions, retry counts, timeout rates, bulkhead rejections.
- Alert on retry rate spike and breaker open duration—leading indicators.
- Runbooks: when to manually trip breaker, drain queues, enable degradation mode.
- Chaos tests: inject latency/failure on dependencies in staging.
- Document degradation tiers (e.g., hide recommendations, keep checkout).
Resilience testing in CI/CD pipeline:
| Stage | Test type | Pass criteria |
|---|---|---|
| Unit | Breaker state transitions mocked | States correct |
| Integration | Testcontainers + Toxiproxy latency | Timeout fires < SLA |
| Staging | Weekly chaos: 500ms downstream delay | Checkout error < 0.1% |
| Pre-prod | Load test with 10% dependency error rate | No metastable failure |
| Prod canary | 5% traffic during deploy | Auto-rollback on burn |
Document resilience SLOs separately from availability SLOs—e.g., "99% of dependency failures fail fast within 100ms" measures breaker effectiveness.
13. Security Considerations
- Rate limiting prevents abuse and accidental DDoS from misconfigured clients.
- Fail-open on auth may expose data—prefer fail-closed for security dependencies.
- Retry amplification can be exploited—authenticate and throttle per tenant.
- Circuit breaker metrics should not leak sensitive dependency topology publicly.
14. Cost Considerations
- Retries increase compute and egress during incidents—model in capacity planning.
- Over-provisioned bulkheads waste resources; under-provisioned cause false failures.
- Managed resilience (mesh, API gateway) adds licensing and operational complexity.
- Incident cost of cascading failure often exceeds resilience infrastructure investment.
15. Production Implementations
Netflix Hystrix (legacy) / Resilience4j
JVM circuit breaker, bulkhead, timeout libraries—Hystrix in maintenance; Resilience4j successor.
Istio / Envoy
Outlier detection, connection pool limits, retries at data plane—implementation with careful policy governance.
AWS ALB + API Gateway
Timeouts, throttling, WAF—edge resilience before application patterns.
gRPC
Built-in deadlines, retry policy (service config), keepalive.
Polly (.NET)
Policy composition: retry, circuit breaker, bulkhead, timeout.
Cross-implementation comparison (selection guide):
| Environment | Recommended starting point | Rationale |
|---|---|---|
| JVM microservices | Resilience4j + Micrometer metrics | Active maintenance; Spring Boot integration |
| Kubernetes polyglot | Istio outlier detection + app timeouts | Uniform policy without per-language libs |
| AWS Lambda | API Gateway timeout + idempotent handlers | No long-lived thread pools |
| .NET services | Polly v8 pipelines | Composable policies with DI |
| Mobile BFF | Client-side backoff + server idempotency | Cannot rely on server-only breakers |
Netflix historical context: Hystrix demonstrated circuit breaker patterns at scale but was designed for thread-per-request servlet models. Reactive and virtual-thread architectures may use lighter-weight alternatives—but the patterns remain valid regardless of library. Teams migrating off Hystrix should preserve metrics dashboards during Resilience4j migration to avoid blind spots.
Edge vs application resilience split: API Gateway handles coarse rate limits and WAF; application handles idempotency and business-aware degradation. Duplicating circuit breakers at both layers without coordination can cause confusing partial failures—document which layer owns which concern.
16. Alternatives and Tradeoffs
| Approach | Strength | Weakness |
|---|---|---|
| Client-side libraries | Fine-grained per call | Language fragmentation |
| Service mesh | Uniform policy | Operational complexity |
| API gateway aggregation | Reduces fan-out | Single point of failure if not HA |
| Async + queue | Natural decoupling | Higher latency to consistency |
| Synchronous + patterns | Low latency happy path | Complex tuning |
Prefer async boundaries for non-critical paths; sync + resilience for latency-sensitive critical paths.
17. Common Misconceptions
| Misconception | Reality |
|---|---|
| "Retry everything" | Retries unsafe without idempotency; amplifies outages |
| "Circuit breaker fixes slow deps" | It protects callers; root cause still needs fixing |
| "Longer timeout = more reliable" | Long timeouts exhaust pools; fail faster |
| "Mesh solves resilience" | Policies still need correct values and idempotent apps |
| "Bulkhead = K8s resource limits" | Different—thread/connection isolation per dependency |
18. Principal Architect Perspective
- Platform defaults for timeout, retry, breaker—teams opt out with ADR, not opt in blindly.
- Idempotency is prerequisite for any retry on mutations—enforce at API design review.
- Degrade features by tier before losing core transactions.
- Chaos engineering validates patterns under realistic failure—not unit tests alone.
- Metastable failures require load shedding, not just retries—study formal models (e.g., NSDI papers on metastability).
Platform resilience policy template (golden path):
Every outbound client generated from platform SDK should inherit:
timeout: parent_deadline - 50ms
retry: max 2, exponential backoff, full jitter
retry_on: [timeout, 503, 429]
no_retry_on: [400, 401, 402, 404, 409]
idempotency: required for POST/PUT mutations
circuit_breaker: 50% errors / 30s window, open 60s
bulkhead: dedicated pool per dependency
Teams override via ADR with SRE sign-off—not silent local copies.
19. Architecture Review Exercise
Scenario: Mobile app → API gateway → 6 microservices, no timeouts, infinite retries on 500, shared Tomcat thread pool (200 threads).
Review prompts:
- What happens when Recommendations service hangs?
- Retry behavior during payment outage?
- Proposed remediation priority?
Expected findings: Add timeouts (gateway + client), retry cap with jitter, bulkheads per dependency, idempotency on payments, async recommendations with fallback empty list.
20. Whiteboard Explanation
90-second version:
"Every outbound call gets a timeout shorter than the user's deadline, with cancellation propagated. Retries are limited, exponential backoff with jitter, only on idempotent operations or with idempotency keys. Circuit breakers fail fast when error rate spikes—open, then half-open probes before full restore. Bulkheads isolate thread pools so one bad dependency can't starve checkout. Under extreme load we shed non-critical work—hide recommendations, queue notifications. The goal is preventing cascading failure: a slow service shouldn't take down the whole mesh. We measure breaker opens, retry rates, and pool saturation, and chaos-test dependency latency in staging."
21. Interview Questions
-
Circuit breaker states?
- Signals: Closed, open, half-open; thresholds and probes.
-
Why jitter on backoff?
- Signals: Desynchronize retries; prevent thundering herd.
-
Retry without idempotency risk?
- Signals: Duplicate side effects; double charge example.
-
Bulkhead vs rate limit?
- Signals: Pool isolation vs request rate cap.
-
Timeout propagation?
- Signals: Parent deadline minus processing; gRPC context.
-
Fail open vs closed for recommendations?
- Signals: Fail open (empty list); vs payment fail closed.
-
Metastable failure?
- Signals: System can't recover because retry/load prevents healing.
-
Hedging tradeoff?
- Signals: Tail latency vs doubled load.
-
When circuit breaker hurts?
- Signals: False opens; flapping; hides partial degradation needs.
-
Design checkout resilience.
- Signals: Payment idempotency, inventory reservation timeout, async confirmation.
-
Client vs server retry?
- Signals: Both dangerous if uncoordinated; prefer client with server idempotency.
-
Deep vs shallow health check?
- Signals: Shallow for LB liveness; deep for readiness including deps.
-
How detect metastable failure?
- Signals: System not recovering after fix; retry rate high; load exceeds sustainable.
-
Bulkhead thread pool sizing?
- Signals: Based on dependency SLA, pool % of total, load test saturation point.
-
Platform vs app resilience ownership?
- Signals: Platform defaults; app idempotency and degradation logic; ADR for overrides.
Scoring rubric:
| Dimension | Strong | Weak |
|---|---|---|
| Failure reasoning | Cascading, metastable, pools | "Add retry" only |
| Safety | Idempotency, fail closed | Retry all POSTs |
| Ops | Metrics, chaos, runbooks | Library name drop |
22. Interview Follow-Ups
-
How set circuit breaker thresholds?
- Signals: Error rate + slow call % over sliding window; tune from production baselines.
-
Mesh retry on POST?
- Signals: Dangerous; disable or require idempotent protocol design.
-
Graceful degradation without code deploy?
- Signals: Feature flags, config-driven fallbacks, cached responses.
-
How coordinate retry budgets across microservices during incident?
- Signals: Global rate limit on dependency; reduce client max retries centrally via config service.
-
Resilience testing in production canary?
- Signals: Small traffic %; abort on burn; fault injection on canary subset only.
22A. Production Low-Level Design (Interview + Game Day)
Compose timeout, retry, bulkhead, breaker for checkout→payment. Production LLD and Game Day Standard.
Call policy LLD
| Pattern | Setting sketch | Why |
|---|---|---|
| Timeout | < parent deadline | Avoid nested overrun |
| Retry | Max 2, expo+jitter, idempotent only | Bound amplification |
| Bulkhead | Isolated pool for payment | Protect cart browse |
| Breaker | Open on error/slow % | Fail fast + degrade |
Step-by-step flow:
| Step | Safety |
|---|---|
| 1 | Deadline propagation |
| 2 | Same idempotency key on retry |
| 4 | Queue for async pay / cached UX — no blind double charge |
One SLO
Checkout availability with payment success or explicit deferred state; alert on breaker open duration.
22B. Game Day Playbooks
| # | Drill | Inject | Detect | Mitigate | Verify |
|---|---|---|---|---|---|
| GD-1 | Payment 5xx storm | Fault inject payment | Breaker opens | Degrade checkout | Browse alive; no cascade |
| GD-2 | Retry amplification | Short timeout + retries | Retry RPS↑ | Cut budget | Dependency load drops |
| GD-3 | Pool exhaustion | Saturate payment pool | Bulkhead reject | Other pools healthy | Isolation holds |
GD-1 — Breaker protects checkout
23. Strong Answer Example
Question: "Payment dependency is flaky—how do you protect checkout?"
Answer this as a 45-minute greenfield design using the PRACTICE framework. Below is how a strong student sounds aloud—protect checkout liveness without double-charging, then defend timeout/retry/breaker composition.

Figure A: PRACTICE map — Problem → Requirements → Assumptions → Capacity → Topology → Invariants → Constraints → Evolution.
Student interview script (PRACTICE)
P — Problem framing
"Checkout depends on a flaky payment provider—timeouts, 503s, latency spikes. Uncontrolled retries and shared thread pools turn that into a cascading outage of the whole cart/checkout path—and unsafe retries risk double charges.
Non-goals for v1: replacing the payment PSP, building a full ledger, or active-active multi-region checkout. I'll treat bounded sync path + safe async recovery as the core."
R — Requirements
| Type | Requirement |
|---|---|
| FR | Place order, charge card, confirm or park for async payment |
| NFR | Checkout API p99 within latency budget (~1.2s); payment call timeout < parent; 99.9% checkout availability when payment is degraded (not necessarily charged) |
| Safety | No double charge; declines (402) fail closed—no retry |
| Ops | Breaker state, retry rate, pool saturation visible; chaos-test payment latency |
"I'll ask: is payment a third-party PSP or internal? Sync charge required for confirmation, or is
PENDING_PAYMENTOK? I'll assume third-party PSP, sync preferred, async hold allowed when flaky."
A — Assumptions (state aloud)
| Assumption | Why it matters |
|---|---|
Client supplies Idempotency-Key | Safe retries / async re-charge |
| Server-side dedup store (TTL ≥ retry window) | Prevents double charge on timeout ambiguity |
| Checkout has a hard latency budget (~1.2s) | Child timeout must be shorter |
| Payment is flaky, not permanently down | Breaker + half-open; async worker for backlog |
| Inventory/recommendations share the same app | Need bulkheads—payment can't starve them |
"If they say 'must confirm payment before any order row,' I'd push for a reservation / pending state—otherwise flaky PSP = total checkout outage."
C — Capacity (back-of-envelope + pool math)
Checkout QPS (peak) → 2,000 (say)
Payment p99 target → < 300ms healthy; flaky → seconds
Parent deadline → 1.2s
Child payment timeout → 800ms (leaves margin for inventory/commit)
Max sync retries → 1–2 on timeout/503 only (budget permitting)
Bulkhead threads for payment → ~25–40 (sized from QPS × latency + headroom)
e.g. 2000 QPS × 0.05s avg ≈ 100 in-flight → pool + queue caps matter
Breaker → open if ~50% errors or slow calls in 30s window; open 60s
Async worker throughput → drain PENDING_PAYMENT without retry storm
"Capacity here is threads and in-flight calls, not just QPS—one slow PSP without a bulkhead exhausts the checkout pool."
T — Topology (draw this)

Figure B: Checkout owns timeout + retry + breaker + payment bulkhead; on open/budget exceeded → PENDING_PAYMENT + async worker; other deps isolated.
Pattern composition (order matters):
| Layer | Policy |
|---|---|
| Timeout | 800ms child inside 1.2s parent |
| Retry | Max 2; exponential backoff + full jitter; only timeout/503—not 402 |
| Circuit breaker | Fail fast when error/slow rate spikes; half-open probes |
| Bulkhead | Dedicated pool/queue for payment |
| Degradation | Breaker open → PENDING_PAYMENT + async—not infinite sync retry |

Figure C: Idempotency → bulkhead → timed call → selective retry → breaker/async park; declines never retry.
I — Invariants (safety)
"Non-negotiable for checkout + payment:
- Idempotency-Key on every charge—timeout after success must not double-charge.
- Never retry business declines (402 / insufficient funds)—fail closed to the user.
- Retry only when safe and budget remains—timeout/503 with key; cap attempts.
- Breaker open ≠ drop the order silently—park
PENDING_PAYMENTand recover async.- Bulkhead isolation—payment saturation must not block inventory or health endpoints."
C — Constraints (second C)
| Constraint | Design response |
|---|---|
| User-facing latency | Fail fast via breaker; don't wait 30s |
| Ambiguous timeout | Idempotent charge + reconcilation / status poll |
| Mesh retries on POST | Disable mesh retry on charge or require same idempotency key |
| Cost of async UX | Show "confirming payment" / email when charged |
| Chaos / false opens | Tune from baselines; half-open probe count; don't open on tiny windows |
E — Evolution (phased harden + prove)
Phased delivery:
| Phase | Deliverable |
|---|---|
| M1 | Idempotency-Key + dedup store; payment timeout < parent deadline |
| M2 | Retry with jitter (safe codes only); payment bulkhead |
| M3 | Circuit breaker + PENDING_PAYMENT async worker |
| M4 | Dashboards: breaker state, retry rate, pool reject, payment error budget |
| M5 | Monthly chaos: inject 5s payment latency; verify no cascade |
Failure modes I'd mention:
| Failure | Mitigation |
|---|---|
| PSP slow (not erroring) | Timeout + slow-call breaker trip |
| Retry storm on recovery | Jitter; breaker half-open limit; async rate limit |
| Double charge after timeout | Idempotency + PSP dedup |
| Shared thread pool exhaustion | Bulkhead; load-shed recommendations |
| Mesh + app double retry | One owner for retry policy |
Observability: payment_timeout_rate, breaker_state, retry_attempts, bulkhead_rejected, pending_payment_age, checkout SLO vs payment error budget.
Closing line (interview)
"So: idempotency first, then timeout inside the checkout budget, capped jittered retries only on transient codes, circuit breaker to fail fast, bulkhead so payment can't starve checkout, and when the breaker is open—park
PENDING_PAYMENTand charge async—not sync retry forever. I'd chaos-test slow payment so we prove the cascade doesn't happen."
Scoring signals
| Strong | Weak / red flag |
|---|---|
| Idempotency before retry | "Retry three times" |
| Timeout < parent deadline | 30s timeouts |
| Retry only timeout/503—not 402 | Retry all errors |
| Breaker + async park | Breaker only, drop order |
| Bulkhead isolation | Shared pool for all deps |
| Chaos / metrics | Library name drop only |
Compact outline (if time-boxed to 2 minutes)
"Idempotency-Key + dedup. Checkout budget 1.2s; payment timeout 800ms. Retry ≤2 with full jitter on timeout/503 only—never 402. Circuit breaker 50%/30s → open 60s, half-open probes. Payment bulkhead ~25 threads. If open:
PENDING_PAYMENT+ async worker. Metrics + monthly 5s latency chaos."
24. Weak Answer Example
Question: "Payment dependency is flaky—how do you protect checkout?"
"Add a circuit breaker and retry three times."
Why weak / red flags: No idempotency, no backoff/jitter, no bulkhead, no timeout budget, no async fallback—retries without keys risk double charges and cascades.
25. Hands-On Exercise
Try it: Sagas §25 Hands-On — Lab 010 demonstrates timeout/retry, compensation, and idempotent saga steps on :8093.
- Implement Resilience4j (or equivalent) on sample service with breaker + retry + bulkhead.
- Inject 100% failure on dependency; observe open state and recovery.
- Remove jitter; measure retry spike with load generator.
- Add idempotency middleware; verify duplicate POST safety.
- Document degradation tiers for a product page BFF.
- Run chaos test: 2s latency injection; capture thread pool metrics.
- Measure metastable failure: inject 503 on dependency with unlimited client retry; observe recovery time after fix.
- Implement idempotency store (Redis or DB) and verify duplicate charge prevention under parallel retries.
- Document platform SDK default resilience policy; present override ADR template to mock staff panel.
26. Knowledge Check
- Half-open purpose? (Probe recovery with limited traffic.)
- Jitter prevents? (Synchronized retry storms.)
- Bulkhead protects? (Resource pool isolation per dependency.)
- Idempotency needed for? (Safe retries on mutations.)
- Metastable failure? (Overload prevents recovery despite fix.)
27. Flashcards
| # | Front | Back |
|---|---|---|
| 1 | Circuit breaker | Fail-fast after errors; half-open probes recovery. |
| 2 | Bulkhead | Isolated resource pool per dependency. |
| 3 | Exponential backoff | Increasing delay between retries. |
| 4 | Jitter | Random delay to desynchronize clients. |
| 5 | Idempotency key | Safe duplicate request handling. |
| 6 | Load shedding | Reject excess load to survive. |
| 7 | Graceful degradation | Reduced features vs total outage. |
| 8 | Hedging | Duplicate slow request—doubles load. |
| 9 | Fail fast | Short timeout vs hanging threads. |
| 10 | Metastable failure | System stuck in bad state despite fix. |
28. Cheat Sheet
EVERY OUTBOUND CALL
Timeout < parent deadline
Retry: capped, backoff, jitter, idempotent only
Breaker: error + slow thresholds
Bulkhead: dedicated pool
BREAKER
Closed → Open (threshold) → HalfOpen (probe) → Closed
ANTI-PATTERNS
Infinite retry
Retry on non-idempotent POST
Shared pool all deps
Timeout > client SLA
DEGRADATION TIERS
Tier 0: Core transactions
Tier 1: Personalization
Tier 2: Analytics beacons
METRICS
Breaker state, retry count, pool reject, timeout rate
29. Related Concepts
- Partial Failure — foundational failure model
- Idempotency — safe retries
- SLOs, SLIs, and Error Budgets — resilience tied to budgets
- Service Mesh and Sidecars — data-plane resilience policies
- Chaos Engineering — validating resilience
- Event-Driven Architecture — async decoupling alternative
30. References
Primary sources
- Nygard, M. (2018). Release It!, 2nd ed. Pragmatic Bookshelf — circuit breaker, bulkhead, stability patterns.
- Bronson, G., et al. "Metastable Failures in Distributed Systems." OSDI 2021 — formal treatment of retry-induced outages.
Engineering blogs
- Netflix Technology Blog — Hystrix and resilience evolution.
- Microsoft Azure Architecture Center — Circuit Breaker pattern.
- Resilience4j documentation — configuration semantics.
Distinction
| Claim type | Source |
|---|---|
| Pattern definitions | Nygard; Azure patterns catalog |
| Metastable failure | OSDI 2021 paper |
| Library behavior | Resilience4j/Istio docs — implementation choices |