Finding · affects your reliability

A new database connection per request

Opening a fresh database connection on every request spends time and database capacity on setup, and runs into the connection limit long before the database is busy.

Why it matters

Each new Postgres or MySQL connection costs a handshake and memory on the database server. At low traffic it's invisible. At thousands of requests per second, connection setup becomes the work, and the database's connection limit, usually a few hundred, becomes the ceiling.

What it looks like

Connect, query, disconnect, on every request:

Before
export async function GET() {
  const client = new Client(process.env.DATABASE_URL);
  await client.connect();
  const rows = await client.query("select ...");
  await client.end();
  return Response.json(rows);
}

How to fix it

  1. Create one shared pool per process and reuse it.
  2. On serverless, connect through a pooler (RDS Proxy, PgBouncer, a provider's pooled URL), which absorbs per-request connections transparently.

How Skeram detects it

The extraction records each database's connection style. Postgres or MySQL opened per request is flagged, with the connection setups per second the forecast predicts.

When it starts to hurt: A warning from about 1,000 monthly users, critical from about 10,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.

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.