7.2. Protection Patterns
Protection patterns stop one failing dependency from taking down the caller. A circuit breaker stops hammering a dead service and gives it room to recover; a bulkhead isolates resources so one slow dependency cannot exhaust every thread; a retry with backoff and jitter recovers from transient faults without synchronizing into a storm. This chapter covers each pattern’s state machine and failure modes, the timeout configuration that underpins all of them, and the fallback strategies for when protection means degrading gracefully rather than failing outright.
Topics Covered
Section titled “Topics Covered”- 7.2.1. Circuit Breaker: The Closed to Open to Half-Open Cycle: Covers the circuit breaker’s closed, open, and half-open states that stop hammering a failing dependency.
- 7.2.2. Bulkhead Pattern: Thread Pool and Semaphore Isolation: Explains the bulkhead pattern, isolating resources so one slow dependency cannot exhaust every thread.
- 7.2.3. Retry with Exponential Backoff and Jitter: Covers retry with exponential backoff and jitter to recover from transient faults without synchronizing.
- 7.2.4. Timeouts: Why They Are So Hard to Configure: Explains why timeouts are so hard to configure and why deadline propagation beats per-hop timeouts.
- 7.2.5. Fallback Strategies: Degraded Service, Cached Response: Covers fallback strategies — degraded service and cached responses — for when a dependency is unavailable.
- 7.2.6. From Hystrix to Resilience4j: Library Comparison: Compares Hystrix and Resilience4j and the shift from thread-pool isolation to lightweight functional decorators.