Skip to content

Connection Pooler

Medium — good to knowDatabase

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."

Made with passive-aggressive love by manoga.digital. Powered by Claude.