Connection Pooling Beyond PgBouncer: A Custom Approach for Distributed PostgreSQL

Canfor

50-Minute Talk

Connection pooling is critical infrastructure for PostgreSQL at scale, but existing poolers like PgBouncer operate at the protocol level without deep integration into distributed database architectures. This talk presents our experience building a custom connection pooler for multigres, a distributed PostgreSQL system, that natively supports the extended query protocol (Parse/Bind/Execute), per-user connection pools for Row-Level Security compatibility, and prepared statement consolidation across clients.

We'll dive into the technical challenges we encountered: implementing settings-based connection routing with an LRU cache for fast pointer-equality comparisons, managing connection affinity for transactions while maximizing pool utilization, and handling the complexities of PostgreSQL's extended query protocol across a distributed query path. Attendees will learn about our three-tier pool architecture (admin, regular, and reserved pools), how we route connections through hash buckets based on session settings, and the tradeoffs we made between connection reuse and protocol correctness.

Whether you're building database infrastructure, evaluating connection pooling strategies, or curious about PostgreSQL protocol internals, this talk offers practical insights from implementing a production-grade pooler from scratch.

Gold Sponsors

EDB

Microsoft

AWS

Huawei

Silver Sponsors

Percona

Fujitsu

HighGo

Duboce Labs, Inc.