stackbook.io
🔍
resilienceestablished · low operational burden

Bulkhead Pattern

Also known as: bulkhead-isolation, resource-isolation

Intent

Isolate components of a system so that failure in one does not cascadingly fail the entire application, analogous to ship bulkheads preventing water from flooding the entire vessel.

Problem

In distributed systems, a single slow or failed downstream service can exhaust thread pools, saturate connections, and cause cascading failures that take down the entire application. Without isolation, all services share the same resource pools.

Forces

  • •Services depend on other services over the network
  • •Network failures, latency spikes, and timeouts are inevitable
  • •Thread pool exhaustion from blocking calls amplifies failures
  • •Some dependencies are more critical than others
  • •Resource constraints (threads, connections, memory) are finite

Solution

Bulkhead Pattern

Isolate components of a system so that failure in one does not cascade to the entire application, analogous to ship bulkheads preventing water from flooding the entire vessel.

Key Strategies

1. Connection Pool Isolation

Maintain separate connection pools per downstream service. A slow service cannot exhaust the connection pool for other services. Configure pool sizes per service criticality.

2. Thread Pool Isolation

Dedicated thread pools per service or component. Blocking calls in one area cannot starve threads in others. Use bounded queues and backpressure.

3. Resource Budget Allocation

Assign fixed quotas of memory/CPU per service. Ensure critical services always have resources available. Use cgroups, namespaces, or container limits.

4. Circuit Breaker + Bulkhead

Combine with Circuit Breaker for double protection. Bulkhead prevents resource exhaustion. Circuit Breaker prevents calls to failed services.

When to Use

  • Any service with multiple downstream dependencies
  • Preventing cascading failures in distributed systems
  • When some dependencies are more critical than others
  • When thread pool or connection pool exhaustion is a frequent issue

When Not to Use

  • Very small services with a single dependency
  • When all dependencies have similar criticality and failure modes
  • If the overhead of isolation outweighs the risk of cascading failures

Cost Profile

| Category | Assessment | |----------|-----------| | Infrastructure | Low — just separate pool management in service code | | Operational | Low — once configured, self-regulating | | Cognitive | Medium — determining proper isolation boundaries |

Real-World Examples

  • Hystrix thread pools at Netflix: Isolation of failure domains
  • Spring Boot separate thread pools: Per-service thread pool configuration

Alternatives

✓ When to Use

  • •Any service with multiple downstream dependencies
  • •Preventing cascading failures in distributed systems
  • •When some dependencies are more critical than others
  • •Thread pool or connection pool exhaustion is a frequent issue

✗ When Not to Use

  • •Very small services with a single dependency
  • •When all dependencies have similar criticality and failure modes
  • •If the overhead of isolation outweighs the risk of cascading failures

Pros

  • +Prevents cascading failures across services
  • +Allows critical services to continue operating
  • +Well-understood pattern with proven implementations
  • +Combines well with Circuit Breaker

Cons

  • −Requires planning: Need to determine isolation boundaries upfront
  • −Resource overhead: Multiple pools may underutilize resources
  • −Complexity: More configuration and monitoring required
  • −Potential for resource fragmentation if not tuned properly

Cost Profile

Infrastructure

Low — just separate pool management in service code

Operational

Low — once configured, self-regulating

Cognitive

Medium — determining proper isolation boundaries

Failure Modes

  • Under-isolation: One service still affects others through shared resources

  • Over-isolation: Resources idle in one pool while another is starved

  • Misconfigured boundaries: Critical and non-critical services swapped

  • Cache stagnation: Pools starve while others have available capacity

Real-World Examples

Alternatives

  • circuit-breaker
  • timeout-and-retry
  • dependency-isolation

Related Patterns

    Competency Domains

    reliability opssecurity compliance