Course contentsShow
← System Design
Lesson 1071 of 1,91927. Circuit Breakers and BulkheadsFree lesson

Connection Pool Bulkheads: Database and Service Isolation

Partitioning connection pools so that one service's database issues don't starve connections for other services.

Connection Pool Bulkheads: Database and Service Isolation

What you'll learn: How to partition database connection pools so one service's problems don't exhaust connections for everyone else.

The Problem: Shared Connection Starvation

When multiple services share a single database connection pool, a misbehaving service can consume all available connections. Imagine Service A suddenly starts making slow queries that hold connections open for 30 seconds each. If the pool has 100 connections and Service A saturates them, Service B can't get any connections—even though Service B is behaving perfectly.

This is catastrophic cascade failure: one service's database issues starve all other services.

Connection Pool Bulkheads Explained

A connection pool bulkhead partitions your connection pool into isolated segments, each dedicated to a specific service or workload. Instead of one 100-connection pool, you create:

  • Service A: 40 connections (max)
  • Service B: 30 connections (max)
  • Service C: 30 connections (max)

Now if Service A has problems, it can only exhaust its own 40 connections. Services B and C remain unaffected, each guaranteed access to their reserved capacity.

Implementation Approach

You can implement this at multiple levels:

  • Application-level: Each microservice maintains its own connection pool configuration
  • Database proxy layer: Tools like PgBouncer or ProxySQL can enforce per-user or per-application connection limits
  • Connection pool configuration: Libraries allow multiple named pools with different size limits

The key is ensuring each partition is truly isolated—no borrowing from other bulkheads, even when idle.

The Tradeoff

You sacrifice total theoretical efficiency (unused connections in one bulkhead can't help overloaded others) for guaranteed isolation and fault containment. This is exactly like ship bulkheads: you lose some cargo space to the walls, but one leak won't sink the ship.

Key Takeaway: Connection pool bulkheads prevent one service's database issues from starving connections for other services by partitioning the pool into isolated, per-service segments.