Tutorial

Bulkhead Isolation

Partition resources like connection pools by tenant or feature so a flood in one cannot starve the others, and a failure stays contained.

On this page

  1. Introduction
  2. Partition the pool
  3. Cap each partition
  4. Reject when full
  5. Choose the axis
  6. Fallback per partition
  7. Test isolation
  8. Sources

Introduction

This guide covers bulkhead isolation of resources, a recurring concern in the resilience scenario. A shared connection pool means one noisy tenant or one runaway feature can exhaust the pool and take down unrelated calls. Partitioning the pool into bulkheads per tenant or feature means a flood fills only its own compartment, and the failure stays contained instead of spreading.

Partition the pool

Give each tenant or feature its own pool or worker quota so a flood in one fills only its own compartment, which is the containment.

The trade-off worth naming is that give each tenant or feature its own pool or worker quota so a flood in one fills only its own compartment, which is the containment adds a measurable step to the hot path, so measure it before assuming it is free. A reasonable approach is to validate once at the edge, fail closed with a structured error, and log the rejection reason so a spike in bad input is visible on a dashboard rather than silent. Pair the implementation with a test that asserts a valid payload passes and at least one representative violation is rejected with the expected message; this is the cheapest way to keep the guarantee honest as the schema evolves.

const pools = new Map();
function poolFor(tenant) {
  if (!pools.has(tenant)) pools.set(tenant, makePool({ max: 10 }));
  return pools.get(tenant);
}

Cap each partition

Size each partition for its normal load so a flood cannot consume the whole resource, which is the capacity planning behind the bulkhead.

The trade-off worth naming is that size each partition for its normal load so a flood cannot consume the whole resource, which is the capacity planning behind the bulkhead adds a measurable step to the hot path, so measure it before assuming it is free. A reasonable approach is to validate once at the edge, fail closed with a structured error, and log the rejection reason so a spike in bad input is visible on a dashboard rather than silent. Pair the implementation with a test that asserts a valid payload passes and at least one representative violation is rejected with the expected message; this is the cheapest way to keep the guarantee honest as the schema evolves.

Reject when full

When a partition is full, reject or queue rather than borrowing from others, so the bulkhead holds under load.

The trade-off worth naming is that when a partition is full, reject or queue rather than borrowing from others, so the bulkhead holds under load adds a measurable step to the hot path, so measure it before assuming it is free. A reasonable approach is to validate once at the edge, fail closed with a structured error, and log the rejection reason so a spike in bad input is visible on a dashboard rather than silent. Pair the implementation with a test that asserts a valid payload passes and at least one representative violation is rejected with the expected message; this is the cheapest way to keep the guarantee honest as the schema evolves.

function acquire(tenant) {
  const p = poolFor(tenant);
  if (p.inUse >= p.max) throw new Error('partition full');
  return p.acquire();
}

Choose the axis

Partition by tenant to contain a noisy customer, or by feature to contain a runaway endpoint, matching the bulkhead to the failure mode you actually see.

The trade-off worth naming is that partition by tenant to contain a noisy customer, or by feature to contain a runaway endpoint, matching the bulkhead to the failure mode you actually see adds a measurable step to the hot path, so measure it before assuming it is free. A reasonable approach is to validate once at the edge, fail closed with a structured error, and log the rejection reason so a spike in bad input is visible on a dashboard rather than silent. Pair the implementation with a test that asserts a valid payload passes and at least one representative violation is rejected with the expected message; this is the cheapest way to keep the guarantee honest as the schema evolves.

Fallback per partition

Give each partition its own fallback so a saturated compartment degrades its feature rather than failing a shared one, which keeps the blast radius small.

The trade-off worth naming is that give each partition its own fallback so a saturated compartment degrades its feature rather than failing a shared one, which keeps the blast radius small adds a measurable step to the hot path, so measure it before assuming it is free. A reasonable approach is to validate once at the edge, fail closed with a structured error, and log the rejection reason so a spike in bad input is visible on a dashboard rather than silent. Pair the implementation with a test that asserts a valid payload passes and at least one representative violation is rejected with the expected message; this is the cheapest way to keep the guarantee honest as the schema evolves.

Test isolation

Flood one partition and assert another is unaffected, so the bulkhead contains the flood rather than spreading it.

The trade-off worth naming is that flood one partition and assert another is unaffected, so the bulkhead contains the flood rather than spreading it adds a measurable step to the hot path, so measure it before assuming it is free. A reasonable approach is to validate once at the edge, fail closed with a structured error, and log the rejection reason so a spike in bad input is visible on a dashboard rather than silent. Pair the implementation with a test that asserts a valid payload passes and at least one representative violation is rejected with the expected message; this is the cheapest way to keep the guarantee honest as the schema evolves.

Sources

Sources: Bulkhead pattern, Resilience4j.

FAQ

Per-tenant or per-feature bulkheads?
Per-tenant protects against a noisy customer; per-feature protects against a runaway endpoint; pick the axis that matches your failure mode, or both if you can afford the pools.
How big each partition?
Big enough to serve the normal load of that tenant or feature, small enough that a flood cannot consume the whole resource, which is a capacity planning question.

Related Examples