Split resources into separate compartments so one overload cannot sink the whole ship.
The bulkhead pattern splits your resources (threads, connections, memory, even whole servers) into separate compartments, so a problem in one part cannot use up everything.
Imagine a service that calls three others: checkout, reports and search. It handles all calls with one shared pool of 20 threads. One day the reports service becomes very slow. Every report call now holds a thread for 8 seconds. Soon all 20 threads are stuck on reports. Checkout and search are healthy, but they cannot get a thread, so they fail too. One slow neighbour took everyone down.
The bulkhead pattern avoids this by partitioning the resource. For example: 12 threads for checkout, 4 for search and 4 for reports. When reports is slow, its 4 threads fill up, and extra report requests are rejected quickly. Checkout and search still have their own threads, and keep running.
| Style | How it isolates | Good and bad |
|---|---|---|
| Thread-pool bulkhead | A dedicated thread pool per dependency | Strong isolation and a clear timeout. Costs extra threads and context switching. |
| Semaphore bulkhead | A counter limits concurrent calls, calls run on the caller's thread | Light and cheap. A hung call still holds the caller's thread, so timeouts matter. |
| Connection-pool bulkhead | Separate connection pools per database or API | Stops one slow query path from using every connection. |
| Process or container | Separate process, container or VM with CPU and memory limits | Strong isolation, even for memory leaks or crashes. Higher cost. |
| Service or cell | Separate deployments for different traffic or customers | The best isolation, with the most operations work. |
Checkout: 20 requests/s, 100 ms each (needs about 2 threads). Reports: 6 requests/s, 300 ms at first. Slider "Reports compartment" only matters in bulkhead mode.
A simplified model with a simulated clock (no random numbers). A request with no free thread in its pool is rejected at once (no waiting line). Real bulkheads may add a small queue.
| Term | Meaning in easy words |
|---|---|
| Bulkhead | A wall that keeps one part of a system from affecting another |
| Compartment | One isolated share of resources (a pool, a limit, a server) |
| Blast radius | How much of the system is hurt when something fails |
| Noisy neighbour | One user or feature that takes more than its share and hurts others |
| Thread pool | A fixed group of worker threads that run tasks |
| Semaphore | A counter that allows only N things to happen at once |
| Cascading failure | A failure that spreads from one part to the next |
| Resource exhaustion | Running out of threads, memory or connections |
| Load shedding | Rejecting some work on purpose to protect the rest |
| Cell-based architecture | Splitting the whole system into independent copies, each serving part of the users |
| Concurrency limit | The most calls allowed at the same moment |
| Choice | We gain | We lose |
|---|---|---|
| More compartments | Finer isolation | More wasted idle capacity and more settings |
| Fewer compartments | Better use of resources | Weaker isolation, a bigger blast radius |
| Small compartment | A strong cap on damage | Rejections even in normal bursts |
| Large compartment | Handles bursts well | A slow dependency can still hold many resources |
| Thread-pool bulkhead | Strong isolation and clean timeouts | More threads, more context switching |
| Semaphore bulkhead | Very light | Runs on the caller's thread, so a stuck call still holds it |