Group
  • Database

    Set up database connection pooling and timeouts

    Configures a sane connection pool and query timeouts so traffic spikes can't exhaust your database connections.

    • Debug & fix
    • Plan & validate
    • Intermediate
    • General

Free Prompt

Fix my database connection management. Find where the app creates its database connection or client and check how connections are pooled and bounded. Configure: a connection pool sized for the actual environment (a small pool like 5-10 for a single serverless-ish or small server, not one connection per request); a maximum total so concurrent requests wait instead of opening unbounded connections; connection acquisition timeouts so a request fails fast when the pool is exhausted rather than hanging forever; query timeouts so a runaway query can't hold a connection hostage; and idle connection cleanup so stale connections get recycled. Pay attention to how the runtime actually works: if this runs on serverless functions, one long-lived global pool per warm instance is the pattern, not a pool per invocation, and the pool size must be small because many instances multiply connections. Don't change any query logic. Don't add an external pooler service unless the numbers justify it; note it as an option instead. Deliver: the connection configuration changes, the pool size and timeout values with the reasoning, and verification: show the maximum connections the app can open and confirm it stays under the database's limit.

What This Does / How This Helps

Bounds how many database connections the app can open and how long it waits for one, which stops the classic outage where a traffic spike exhausts every connection the database has. Vibe-coded apps typically use whatever default the client library ships with, and the failure shows up only under load: pages hang, requests time out, and the database reports max connections reached. The fix is cheap and the failure is expensive. Serverless makes this worse because every warm instance opens its own connections, so 100 instances with a pool of 10 is 1000 connections against a database that allows 200. You get the sizing math with the fix.

Want to skip doing this by hand?

Fortivibe audits your app for all of the areas these prompts cover (and more).

See What We Check

Related Prompts