A 49× Traffic Spike, 16.6% DB CPU, and an Exhausted Connection Pool

Traffic jumped from 188 to 9,267 req/min and threw 36 5xx alerts in two minutes. The database was barely working—the real culprit was an uncached maintenance check saturating the connection pool.

On this page
  1. The database wasn’t busy
  2. The same-day fix
  3. What else showed up in the logs
  4. Takeaway

In May 2026, a retail membership API I maintained (TypeScript, Express, Prisma, PostgreSQL) got hit by a sudden burst of traffic: 188 req/min jumped to 9,267 req/min in under a minute—roughly a 49× spike. Within two minutes, monitoring fired 36 5xx alerts.

When an API starts returning 5xx under load, the reflexive guess is that the database is overloaded. Checking the telemetry first saved hours of looking in the wrong place.

The database wasn’t busy

Live metrics showed database CPU sitting at 16.6%. The database had plenty of headroom, yet requests were timing out waiting for connections.

Tracing the request path exposed two issues compounding each other:

  1. Every incoming request queried the database for system maintenance status with zero caching. Under normal traffic (188 req/min), a tiny single-row lookup was invisible. At 9,267 req/min, it multiplied connection acquisition across every endpoint.
  2. No wait ceiling or overload shedding. Once the Prisma connection pool filled up, incoming requests queued behind stuck transactions until they failed with generic 500s—and error logs printed verbose payloads under stress.

The same-day fix

Rather than blindly bumping the pool size (which only pushes the failure downstream), I shipped four small, targeted changes the same day:

  • 30-second cache + request coalescing on the maintenance-status lookup: concurrent requests share one in-flight query instead of stamping the pool simultaneously, eliminating the per-request DB hit.
  • Explicit transaction wait timeouts: fail fast instead of holding pool slots indefinitely during a burst.
  • Graceful overload shedding (503 + Retry-After): when the service hits saturation, return an explicit 503 Service Unavailable with a Retry-After header so clients back off cleanly instead of hammering a saturated pool.
  • Sanitized error logging: strip noisy or sensitive context from error logs under load so logging itself doesn’t become a secondary bottleneck.

What else showed up in the logs

Once traffic settled, reading the request logs more carefully surfaced a quieter, chronic issue on the auth endpoint: 43,477 daily login-refresh requests with a 76% rejection rate, firing in sub-20ms bursts from the same clients.

That wasn’t a backend bug—it was the mobile client entering a tight refresh loop whenever it held an expired credential. Returning a distinct, unambiguous business error code from the API broke the loop and gave the mobile team a clear signal to fix the client-side state machine.

Takeaway

During a spike, the most expensive query is often the cheapest-looking one that runs on every request. Check DB CPU before blaming DB capacity, coalesce hot config reads, and make sure your API speaks 503 before it starts throwing 500.