The name comes from shipbuilding: bulkheads divide the hull into watertight compartments, so a breach in one does not sink the whole ship. In software systems, separate pools of threads, connections and memory play the role of bulkheads: a hung dependency exhausts its own limit and stalls on its own, while the rest of the system keeps working.
What is divided and how
| Resource | How it is divided | Example |
|---|---|---|
| Execution threads | a separate pool per external dependency | the payment gateway call gets its own 20 threads, search — its own 40 |
| Database connections | pools per service or tenant | the reporting module gets 5 connections out of 100, not the whole database |
| Process and memory | separate containers with CPU and memory limits | the recommendation generator does not share memory with the payment service |
| Service instances | groups of nodes by importance of consumers | the critical order flow is served by dedicated nodes, not ones shared with analytics |
Example
A service handles requests with 200 worker threads and calls two external APIs. Without isolation, a hung partner API can take up all 200 threads — and both user sign-in and the shopping cart go down with it. With bulkheads, 50 slots are set aside for partner API calls: the worst case is that the partner API is unavailable, while sign-in and the shopping cart keep working on the remaining 150.
Bulkhead bulkhead = Bulkhead.of("partner-api", BulkheadConfig.custom() .maxConcurrentCalls(50) // compartment capacity (25 by default) .maxWaitDuration(Duration.ofMillis(100)) // wait for a slot for at most 100 ms, then reject .build());In resilience4j, a compartment is a semaphore on the number of concurrent calls; there is also a variant built on a separate thread pool with a queue. When a compartment is full, a new call waits for a free slot for at most the specified time and is then rejected — instead of hanging in the common pile of threads.
When to use it
- resources need to be isolated for specific dependencies, so that a failure in one does not touch the whole application
- critical consumers need to be separated from ordinary ones and given their own service level
- a cascading failure needs to be stopped before it spreads through shared resources
Granularity is chosen based on load and availability requirements: for example, one compartment per tenant, or several tenants per compartment; each compartment is monitored separately, including its SLA. Bulkheads rarely work alone — they are combined with retries, circuit breakers and rate limiting. The cost of the approach is that resources sit idle in empty compartments and configuration becomes more complex; if the project is not prepared for such overhead, the pattern is not used.
Origin of the term
The pattern joined the stability patterns from Michael Nygard’s book “Release It!” (Pragmatic Bookshelf, 2007; second edition 2018). At production scale, bulkheads were cemented by libraries such as Hystrix and resilience4j, along with platform limits — request quotas and container resource limits in Kubernetes.
Sources
the term is written from these pages- Microsoft Azure Architecture Center — Bulkhead patternlearn.microsoft.com/en-us/azure/architecture/patterns/bulkhead(opens in a new tab)
- resilience4j — Bulkheadresilience4j.readme.io/docs/bulkhead(opens in a new tab)
- Michael Nygard — Release It! is released (2007)michaelnygard.com/blog/2007/03/release-it-is-released/(opens in a new tab)
Verified 8 Nov