Connection Pooler
ELI5 — The Vibe Check
A connection pooler keeps a stash of open database connections ready to go, like having pre-heated ovens in a bakery. Instead of each request opening a new connection (slow and expensive), it grabs one from the pool, uses it, and puts it back. Essential for serverless apps that would otherwise overwhelm the database with thousands of short-lived connections.
Real Talk
A connection pooler maintains a pool of persistent database connections that are reused across application requests, reducing the overhead of connection establishment (TCP handshake, TLS, authentication). It limits the total number of connections to the database while serving many more concurrent clients. Common poolers include PgBouncer, pgcat, and built-in framework pools.
Show Me The Code
// Node.js pg-pool example
const pool = new Pool({
max: 20, // max connections in pool
idleTimeoutMillis: 30000,
connectionTimeoutMillis: 2000,
});
const result = await pool.query('SELECT * FROM users WHERE id = $1', [userId]);
When You'll Hear This
"Without a connection pooler, our serverless functions would exhaust Postgres connection limits." / "Set your pool size based on your database's max_connections, not your app's concurrency."
Related Terms
Database Proxy
A database proxy sits between your app and your database like a bouncer at a club.
Neon
Neon is serverless Postgres that can branch like Git. Need to test a migration? Branch your entire database.
PgBouncer
PgBouncer is a lightweight connection pooler that sits in front of PostgreSQL and recycles database connections like a good environmentalist.
Upstash
Upstash gives you Redis and Kafka as serverless services with per-request pricing.