Resilience Patterns
Patterns that help distributed services degrade gracefully under failure, preventing cascading outages.
// concept
In distributed systems, failures are inevitable. Resilience patterns protect your system by detecting failures early, isolating them, and recovering automatically — rather than letting a single failing component take down the entire service.
Circuit Breaker
Prevent cascading failures by switching between CLOSED, OPEN, and HALF_OPEN states based on failure thresholds.
Retry with Backoff
Automatically retry failed operations with exponentially increasing delays and optional jitter to avoid thundering herds.
Timeout Wrapper
Race an async operation against a deadline — if it takes too long, abort and fail fast instead of waiting forever.
Bulkhead
Isolate concurrent workloads with execution slots and a bounded queue — prevent one overwhelmed resource from starving others.
Hedged Requests
Fire duplicate requests after a delay and use whichever responds first — tame tail latency by racing redundant calls.
Fallback Strategy
Chain alternative providers to gracefully degrade — try primary, then secondary, cache, and finally a static default.