Module 5 - Architecture Patterns

Bulkhead Pattern

Isolate failures by partitioning resources into separate compartments.

1The Ship Analogy

Simple Analogy
Ships have watertight compartments (bulkheads). If one compartment floods, the others stay dry and the ship stays afloat. Software bulkheads work the same way-isolate failures so they don't sink the whole system.

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

1Bulkhead isolates failures to prevent system-wide impact
2Use separate thread/connection pools per dependency
3Complements Circuit Breaker-use both together
4Trade-off: more resource overhead for better isolation
5Essential for resilient microservices

?Quiz

1. Slow payment service exhausts all threads. Users can't browse. What pattern helps?

2. Bulkhead is named after: