Postgres Support Case Recap
The Postgres error "remaining connection slots are reserved for non-replication superuser connections" (SQLSTATE 53300) occurs when concurrent connections hit max_connections minus the slots reserved for superusers, e.g. 108 usable of 112 on a 0.25 CU Neon compute. Neon derives max_connections from compute RAM (max(100, min(RAM/9,531,392, 4000))), giving roughly 112 to 3154 connections across compute sizes. Fixes include finding and terminating idle or long-running sessions via pg_stat_activity and pg_terminate_backend, moving to a larger compute, or enabling PgBouncer connection pooling by adding a -pooler suffix to the endpoint hostname, which supports up to 10,000 client connections.
Related posts
- Using Neon’s Scale to Zero with Long-Running Applications
Neon mediumAdept
Neon's scale to zero suspends a Postgres compute after an idle window (only when no WAL senders are active and autovacuum isn't running), which severs connections held by long-running servers. A naive node-postgres Client crashes on the resulting unhandled error event. A client-side pg.Pool with an error handler tolerates the dropped connections and reconnects on demand, waking the database. In Apache Bench tests the pool beat per-request connections by more than 10x (about 46ms vs 678ms average latency, 370 vs 26 req/s), with the same pattern shown in a Fastify, Drizzle and HTMX example app.
- 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.
- 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.
- 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.