Why we built yet another Postgres connection pooler
PgDog is a Rust Postgres proxy whose connection pooler avoids the leaky abstractions of PgBouncer and RDS Proxy. Its built-in SQL parser tracks per-client SET state and resyncs server connections with pipelined SET statements, so session variables and RLS policies keep working. LISTEN/NOTIFY is proxied through Tokio broadcast channels within a process and a dedicated Postgres connection across processes. Multithreading on Tokio lets one process serve more clients with fewer server connections than sharded pools under SO_REUSEPORT or autoscaling. PgDog has been in production for over a year at 2M queries per second.
Related posts
- PgDog vs. RDS Proxy
PgDog mediumAdeptPgDog avoids RDS Proxy's connection pinning, which silently disables transaction pooling when apps use SET, temporary tables, advisory locks, or queries over 16 KB, and can exhaust Postgres connections. PgDog instead transplants session state between server connections and parses queries up to 1 GB with a built-in Postgres parser. Its multithreaded design shares one pool across many clients, whereas RDS Proxy's autoscaled instances each keep separate pools and open more database connections. A pgbench SELECT 1 benchmark shows PgDog roughly 2x faster. The tradeoff is self-hosting via Helm or an experimental ECS Terraform module.
- PGKeeper: Building the bouncer we needed for Postgres
Figma mediumAdept
Figma replaced PgBouncer with PGKeeper, a Go service built on PGX that sits between its DBProxy router and each Postgres instance. Clients reach it over gRPC with per-query metadata such as traffic tier and request source. PgBouncer was ruled out for its single-threaded scaling ceiling, lack of prioritization and backpressure, and weak protection against connection churn. Pooling inside DBProxy was ruled out because hundreds of replicas cannot share a ~100-connection pool, and PGCat would have required a fork. PGKeeper token-bucket rate-limits both connection creation and teardown, warms pools before taking traffic, and avoids churn with bounded result draining, automatic ROLLBACK, and context cancellation via pg_cancel_backend plus SELECT 1. Its priority-based semaphore admission control uses CoDel to shed stale lower-priority work during concurrency spikes.
- PgBouncer is now available in Supabase
Supabase mediumAdeptSupabase now bundles PgBouncer, co-located on the same server as each new project's Postgres, so serverless functions that open a connection per request don't overwhelm the database. The pooler keeps a fixed set of connections open, currently a pool size of 15, and queues clients when all are busy rather than raising Postgres's connection limit. Three pool modes are available: session (full feature support), transaction (recommended for serverless, but no session features like prepared statements) and statement (no multi-statement transactions, suited to autocommit). Pooling applies to new projects only.
- Supavisor: Scaling Postgres to 1 Million Connections
Supabase mediumAdeptSupavisor is a multi-tenant Postgres connection pooler written in Elixir that Supabase built to replace single-threaded PgBouncer. In benchmarks one 16-core instance held 250,000 client connections over a 400-connection database pool, and a 64-core instance held 500,000. Two 64-core nodes, one connected to the database and one relaying through it, held 1,003,200 connections at 20,000 QPS. Median query latency was under 2ms at 5,000 QPS, but running the pooler as a separate cluster adds about 2ms per query compared with co-located PgBouncer, in exchange for not consuming the database server's CPU and RAM.
- Supavisor 1.0: a scalable connection pooler for Postgres
Supabase mediumAdeptSupavisor 1.0, Supabase's Elixir-based Postgres connection pooler, is production-ready and adds query load balancing, named prepared statement support in transaction mode, and query cancelation. All SQL is now parsed via pg_query.rs through Rustler. Reads are randomly spread across primary and replicas, while writes find the primary by probing until a write succeeds, which adds a few milliseconds but makes failover transparent. PREPARE statements are broadcast to all backend connections, trading some memory for throughput. The release also raises default client limits for smaller projects and uses IPv4-to-IPv6 mediation to avoid AWS IPv4 charges.