0

Connections & pooling (Supavisor)

Opsused in ~75% of apps

DevLog works perfectly on your machine, then you deploy it to Vercel and every third request starts failing with FATAL: remaining connection slots are reserved for non-replication superuser connections. You didn't change a line of application code. What changed is that a serverless platform runs your database query in a fresh function invocation, and a fresh invocation means a fresh Postgres connection — dozens of them, all at once, all fighting over a limit that was never designed for that traffic shape.

Core idea. A Postgres connection is a real operating-system process, expensive to open and capped by max_connections. Supavisor sits in front of Postgres and multiplexes many client connections onto a small, fixed pool of real ones. It has two modes that differ in exactly one way — WHEN a connection is handed back to the pool — and that one difference is the reason prepared statements, SET, and session state either work or silently break.
Playground, this isn't a screenshot
Modepool size = 3
req1
req2
req3
req4
req5
req6
Supavisor pool
·
·
·
prepared stmts: OFF
Postgresmax_connections
0 / 6 completed

Transaction mode: a slot is returned to the pool the instant a transaction commits. All 6 requests finish, in waves of 3 — Postgres never sees more than 3 connections at once, no matter how many clients call in. The price: nothing about a client survives between its own statements, so a second query from the same request may land on a differentbackend connection. Prepared statements, `SET`, and session-scoped state don't travel with it.

↑ play a little first, then dig in