Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Neon · Const

Connection pooling

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.

How it works

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.

Syntax

postgresql://USER:PASSWORD@ENDPOINT_ID-pooler.REGION.aws.neon.tech/DATABASE?sslmode=require&channel_binding=require

Key points

  • Neon provides managed PgBouncer pooling and supports up to 10,000 concurrent client connections.
  • Pooling reduces pressure from PostgreSQL’s max_connections limit by reusing database connections.
  • PgBouncer routes many client connections through fewer real PostgreSQL connections instead of creating one for every client.
  • Pooling is selected through the connection string rather than an application-side Neon setting.
  • The pooled hostname is formed by adding -pooler after the endpoint ID.
  • Pool capacity is allocated per user/database pair and is sized to 90% of the compute’s max_connections value.

Example: Use the pooled endpoint

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.

When to use it

Elastic application traffic

Serverless functions and edge runtimes create many concurrent, short-lived database connections.

Connection-per-request workloads

Web applications use connection-per-request frameworks and need to avoid exhausting PostgreSQL connections.

Administrative and migration operations

Migrations, pg_dump, and logical replication require a direct connection because they rely on session-level behavior.

Interview questions

QHow does Neon connection pooling work?

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.

QWhen should an application use the pooled 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.

QWhat limitations does transaction pooling impose?

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.

  • PgBouncer
  • pooled connection string
  • direct connection
  • transaction mode
  • max_connections
  • serverless functions

Source: Connection pooler Thousands of connections. Checked 2026-10-16.