# Serverless connection storm
Symptom: during a traffic spike, database errors spike too, with pool timeouts or refused connections. The Atlas Connections metric jumps in steps matching function concurrency.
## Diagnose
Compute the ceiling: concurrent function instances x `maxPoolSize` per client. With 500 instances and a default pool of 100, that is 50,000 attempted connections. Compare with the tier cap.
## Confirm
Check whether the client is created inside the handler (the bug: every invocation gets its own pool) or outside (correct: warm instances share). One glance at the code answers it.
## Fix
1. Move client creation outside the handler so warm instances reuse one client.
2. Shrink `maxPoolSize` to 1-5 for functions; a function instance runs few concurrent operations.
3. Cap function concurrency at the platform level so the product (instances x pool) stays under the Atlas cap with headroom.
4. Consider a reserved-concurrency pool or a connection proxy if the platform supports it.
## Verify
Replay the traffic spike: Connections plateaus at the computed ceiling, no pool errors, and p95 latency holds.