Elastic application traffic
Serverless functions and edge runtimes create many concurrent, short-lived database connections.
Neon · Const
Neon connection pooling uses PgBouncer in transaction mode to multiplex many client connections over fewer PostgreSQL connections. Select it with a connection string whose endpoint ID has the -pooler suffix; use a direct connection when session state is required.
Neon places PgBouncer in front of PostgreSQL for pooled connections. Multiple client connections share a smaller set of database connections, so applications with many short-lived or concurrent requests should use a hostname whose endpoint ID ends in -pooler; operations requiring session state should use the direct hostname instead.
postgresql://USER:PASSWORD@ENDPOINT_ID-pooler.REGION.aws.neon.tech/DATABASE?sslmode=require&channel_binding=requiremax_connections limit by reusing database connections.-pooler after the endpoint ID.max_connections value.const pooledUrl = process.env.DATABASE_URL?.replace(/(ep-[^.]+)/, "$1-pooler");
if (!pooledUrl) throw new Error("DATABASE_URL is required");
const response = await fetch("https://example.com/api/query", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ databaseUrl: pooledUrl, sql: "select now()" })
});
if (!response.ok) throw new Error(`Request failed: ${response.status}`);A serverless request can use a pooled Neon connection string by adding -pooler to the endpoint ID.
Serverless functions and edge runtimes create many concurrent, short-lived database connections.
Web applications use connection-per-request frameworks and need to avoid exhausting PostgreSQL connections.
Migrations, pg_dump, and logical replication require a direct connection because they rely on session-level behavior.
Neon uses PgBouncer in transaction mode. It multiplexes many client connections over a smaller pool of actual PostgreSQL connections, helping applications stay within the database connection limit.
Follow-up: Which hostname selects the pooler? Add -pooler to the endpoint ID in the connection string; removing it selects the direct connection.
Use the pooled connection string for serverless functions, edge runtimes, and workloads that create many short-lived connections. The pooled endpoint can accept up to 10,000 concurrent client connections.
Follow-up: What should schema migrations use? They should generally use the direct connection because migration tools may depend on session-level behavior.
Pooled connections operate in transaction mode, so session state cannot reliably persist between transactions. SET, temporary tables, and SQL-level PREPARE/DEALLOCATE are unsupported there, while protocol-level prepared statements are supported.
Follow-up: Why can a direct connection be necessary for LISTEN/NOTIFY? It depends on session-level state, which transaction pooling does not preserve.
PgBouncerpooled connection stringdirect connectiontransaction modemax_connectionsserverless functions