Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

PgDog 5 min read Opinion mediumAdept

PgDog vs. RDS Proxy

PgDog 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.

Assumes: PostgreSQL connection poolingtransaction-mode poolingKubernetes Helm

Related posts

  • 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.

  • Let Your AWS Lambdas Survive Thousands of Connections

    Neon mediumAdept

    Lambda's per-instance database connections can overwhelm Aurora Serverless v2 during traffic spikes, causing connection exhaustion, lingering zombie connections and cold-start latency, and RDS Proxy adds cost, pinning issues and borrow latency without fully fixing it. Neon's alternative is PgBouncer built into every endpoint in transaction pooling mode, enabled by adding '-pooler' to the hostname. It accepts up to 10,000 client connections, multiplexes them onto 64 server connections per user/database pair, and queues requests instead of rejecting them. A walkthrough builds a logistics API with a Postgres schema, node-postgres and the Serverless Framework to exercise the pooled setup.

  • PgBouncer is now available in Supabase

    Supabase mediumAdept

    Supabase 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.

  • How we scale PgBouncer in ClickHouse Managed Postgres

    ClickHouse mediumAdept

    Because PgBouncer is single-threaded, ClickHouse Managed Postgres runs a fleet of PgBouncer processes sized to the core count, all binding one port via so_reuseport so the kernel load-balances connections behind a single endpoint. Peering between processes forwards cancel requests that land on the wrong process, and max_client_conn and max_db_connections are divided across the fleet so Postgres is never oversubscribed. On a 16-vCPU c7i.4xlarge with pgbench select-only load, a single process peaked near 87k TPS and degraded to 77k at 256 clients while pinned at one core. A 16-process fleet reached about 336k TPS (roughly 4x) using about 8 cores. At very low concurrency the single process is marginally faster, so the fleet pays off only once the pooler becomes the bottleneck.

  • Supavisor 1.0: a scalable connection pooler for Postgres

    Supabase mediumAdept

    Supavisor 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.

The quest for software engineering knowledge.

Look:
Layout: