Bulkhead Pattern
Isolate failures by partitioning resources into separate compartments.
1The Ship Analogy
The Bulkhead Pattern isolates elements of an application into pools so that if one fails, the others continue to function.
2How It Works
Thread Pool Isolation
Each service call gets its own thread pool. One slow service can't consume all threads.
Connection Pool Isolation
Separate connection pools per dependency. One DB issue doesn't exhaust all connections.
Semaphore Isolation
Limit concurrent calls per service. Lighter than thread pools.
Process Isolation
Run services in separate processes or containers. Strongest isolation.
3Without vs With Bulkhead
Without Bulkhead
- ✗ Slow Service A exhausts all threads
- ✗ Service B, C, D can't get threads
- ✗ Entire application becomes unresponsive
With Bulkhead
- ✓ Service A has its own 10-thread pool
- ✓ Service A issues only affect its pool
- ✓ Services B, C, D continue working
4When to Use
Multiple Dependencies
Calling several external services
Critical vs Non-Critical
Protect critical paths from non-critical failures
Varying SLAs
Different services have different reliability
Shared Resources
Thread pools, connection pools, memory
5Key Takeaways
?Quiz
1. Slow payment service exhausts all threads. Users can't browse. What pattern helps?
2. Bulkhead is named after: