When the database refuses connections.
WHAT THE SYMPTOM IS
An application reporting too many connections, and the site failing.
WHAT CAUSES IT
Connections not released A slow query holding connections while requests pile up Genuine traffic beyond capacity A limit set too low
WHY RAISING THE LIMIT IS RARELY THE ANSWER
Each connection consumes memory, and raising it can exhaust the machine.
WHAT TO ESTABLISH
What is holding the connections.
HOW
The process list, showing state and duration.
WHAT SLEEPING CONNECTIONS MEAN
Open but idle, held by an application.
WHAT CAUSES A BUILD-UP OF THEM
Connections not closed A pool sized larger than needed
WHAT CONNECTION POOLING PROVIDES
Reuse of a fixed set, rather than one per request.
WHAT TO SIZE A POOL BY
Concurrency actually needed, which is far lower than most assume.
WHY SMALLER IS FREQUENTLY FASTER
Fewer connections contend less, and the database does more work.
WHAT TO SET FOR IDLE CONNECTIONS
A timeout closing them.
WHAT TO CHECK ON SHARED HOSTING
Per-account limits, which are separate from the server's.
WHAT TO DO IN AN EMERGENCY
Identify and terminate the longest-running offender.
WHAT TO FIX AFTERWARDS
Whatever allowed it.