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:
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
- Create one shared pool per process and reuse it.
- 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
- Unauthenticated routes that use your users' stored API keys: If users save their own model API keys in your app, a route that uses them without checking who's calling lets strangers spend your users' money.
- Background jobs that run inside requests: Work fired off from a request handler without a queue dies on deploys and crashes, never retries, and competes with live requests for the same server.
- Webhooks processed synchronously: A webhook handler that does its work before responding makes the sender retry under load, which doubles the traffic on an already slow handler.
- 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.
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.