Finding · affects your reliability

Database connection pools on serverless

On serverless hosting every concurrent function instance opens its own pool, so the total quickly exceeds what the database allows.

Why it matters

A connection pool makes sense in one long-running server. On Vercel, Netlify or Lambda, each concurrent function instance is its own process with its own pool, so a pool of 10 times 200 concurrent instances is 2,000 connections. Postgres is usually configured for a few hundred.

Past that, new requests fail with "too many connections" even though the code "uses pooling" and the database isn't busy.

What it looks like

A per-instance pool, deployed on serverless:

Before
// lib/db.ts, deployed on Vercel
export const db = new Pool({ connectionString: process.env.DATABASE_URL, max: 10 });

How to fix it

  1. Put a connection pooler in front of the database (PgBouncer, RDS Proxy, Neon's or Supabase's pooled URL) and point serverless functions at it.
  2. Or move steady traffic to long-lived containers, where one pool per instance is what pools were designed for.
  3. Keep each function's own pool tiny (1–2) when it talks to a pooler.

A real example: Dub

Computed by Skeram’s engine from the published teardown of Dub, at 100,000 monthly users (critical):

Connection pools on serverless multiply per function instance. Deployed on vercel — every concurrent function instance owns its own pool. ~16 concurrent instances at 100,000 users × pool size quickly exceeds max_connections, even though the code "uses pooling".

Suggested fix: Put PgBouncer/RDS Proxy in front, or move steady traffic onto long-lived containers (the Fargate architecture shown here).

Evidence: prisma/schema/schema.prisma:1-9, app/api/me/route.ts.

How Skeram detects it

Skeram reads how the app connects to its database and where it's deployed. A pooled SQL connection on a serverless host is flagged, and the forecast shows the concurrent instances at the slider's audience.

When it starts to hurt: A warning from about 10,000 monthly users, critical around 100,000.

Every finding cites the file and line it came from, and scanning again after a fix shows it resolved in History. How the analysis works.

Questions

I use Prisma. Isn't that pooled?

Prisma pools per process. On serverless that's per function instance, which is exactly the problem. Use a pooled connection string or Prisma Accelerate.

Related findings

Find it in your code

Skeram reads your repo, prices every model call from 100 to 100,000 users, and flags these patterns with the file and line.