---
title: "Give each outside dependency its own pool · Agent Wranglers"
url: https://agentwranglers.se/playbook/architecture/system-architecture/bulkheads
id: ARC-90
level: Recommended
updated: 2026-10-27
build: a2a6bdfed830
tokens: 897
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Give each outside dependency its own pool

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [System architecture](https://agentwranglers.se/playbook/architecture/system-architecture.md).

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers.md). Updated 2026-10-27.

- ID: ARC-90
- Level: Recommended
- Chapter: [System architecture](https://agentwranglers.se/playbook/architecture/system-architecture.md)
- Rule: Give each outside service the app calls its own connection pool or limit on calls at once. A slow or failing service then uses up only its own share.
- Check: A test makes one provider hang and sends traffic that needs a second provider. Calls to the second provider still finish within their normal time.
- How: With one shared pool, a provider that hangs holds every connection, and calls to healthy services wait too. This is the bulkhead pattern, named after the walls in a ship's hull. Size each pool from the calls at once that the service needs at peak. Combine it with [Set timeouts on every call](https://agentwranglers.se/playbook/api-design/reliability/timeouts.md) and a [circuit breaker](https://agentwranglers.se/playbook/operations/capacity-and-resilience/circuit-breakers.md). Slow background work gets its own workers in the same way, so it cannot take the threads that serve pages.

## Examples

**Using these examples:** they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.

### TypeScript example

```ts
// Each provider gets its own limit on calls at once
import pLimit from 'p-limit';
const shippingCalls = pLimit(10);
const paymentCalls = pLimit(20);

const quote = (parcel: Parcel) => shippingCalls(() => shippingApi.quote(parcel));
const charge = (order: Order) => paymentCalls(() => paymentApi.charge(order));
```

### Python example

```python
# Each provider gets its own connection pool
shipping = httpx.AsyncClient(base_url="https://shipping.example.com",
                             limits=httpx.Limits(max_connections=10), timeout=2.0)
payments = httpx.AsyncClient(base_url="https://payments.example.com",
                             limits=httpx.Limits(max_connections=20), timeout=5.0)
```

## Sources

- [Microsoft: Bulkhead pattern](https://learn.microsoft.com/en-us/azure/architecture/patterns/bulkhead)

## Related rules

- API-35 [Set timeouts on every call](https://agentwranglers.se/playbook/api-design/reliability/timeouts.md) in API design
- OPS-74 [Stop calling a failing service with a circuit breaker](https://agentwranglers.se/playbook/operations/capacity-and-resilience/circuit-breakers.md) in Operations and observability

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which requires credit with a link. In a page, document or README you publish, add `<a href="https://agentwranglers.se/playbook/architecture/system-architecture/bulkheads">Agent Wranglers clean code and architecture playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Choose how fresh each piece of shared data must be](https://agentwranglers.se/playbook/architecture/system-architecture/consistency-model.md)
- Next: [Run a change across services as a saga with undo steps](https://agentwranglers.se/playbook/architecture/system-architecture/sagas.md)
- [System architecture](https://agentwranglers.se/playbook/architecture/system-architecture.md)
