Resiliency Patterns
4 min read Quiz at the end
Layer circuit breaker, bulkhead, retry, timeout, and fallback for comprehensive microservices resiliency.
Resiliency Patterns
| Pattern | Problem | Solution |
|---|
| Circuit Breaker | Cascading failures | Stop calling after N failures |
| Bulkhead | Resource exhaustion | Isolate thread pools |
| Retry | Transient failures | Retry with exponential backoff |
| Timeout | Slow dependencies | Fail fast after deadline |
| Fallback | Service unavailable | Return cached or default |
| Rate Limiter | Overload | Throttle incoming requests |
| Saga | Distributed transactions | Compensating actions |
# Combined: circuit breaker + retry
@breaker # outer guard
@retry(stop=stop_after_attempt(3),
wait=wait_exponential(min=1,max=8)) # inner retry
def call_inventory(items):
return httpx.post('http://inventory/reserve',
json=items, timeout=3.0).json()