# The Bulkhead Pattern: Containing Failures
Ships are divided into watertight compartments so one breach doesn't sink the whole vessel. Software bulkheads do the same: isolate resources so one failing part can't exhaust what everything else needs.
## The problem
A service calls three dependencies using one shared thread pool. One dependency becomes slow; requests to it pile up and hold every thread; now calls to the healthy dependencies also fail. One slow component took down the whole service.
## Bulkhead techniques
- **Separate thread pools or concurrency limits per dependency**: the slow dependency can use at most its own 20 slots; the rest keep working.
- **Separate connection pools** per downstream database or service.
- **Per-tenant limits**: one heavy customer can't starve others (quotas, separate queues, or dedicated shards for the biggest tenants).
- **Separate deployments for critical paths**: run checkout on its own instances, isolated from batch exports.
- **Cell-based architecture**: split the whole system into independent cells, each serving a subset of users. A bad deploy or poison request affects only one cell.
## Pairing with other patterns
Bulkheads limit how much damage spreads; **timeouts** bound how long each call waits; **circuit breakers** stop calling a dependency that keeps failing. Together they turn cascading failures into partial ones.
## Sizing
Base limits on measured latency and throughput (Little's law: concurrency = throughput x latency), and alert when a bulkhead is frequently full.
## Interview tip
When asked "what if dependency X gets slow?", answer with timeouts, a dedicated concurrency limit for X, and a fallback. That's the bulkhead mindset in one sentence.
Disclosure: I'm on the Linkjob AI team (https://www.linkjob.ai/), an AI assistant for interview prep.
https://paster.abhicracker.com/A9jVmySx.txt