So we have a large number of scripts running on our server that periodically open up mysql connections and we are generally good about closing the connections as soon as they are done being used.
Lately though we've been seeing massive spikes in connections (upwards of 8000) which crash our server. The outage only lasts a few seconds but it throws a whole bunch of dependent functions into disarray and although manageable is obviously undesirable.
My guess is somewhere a script is running that causes connections to be opened in some kind of loop, possibly a cron.
Problem is I can't seem to find a pattern of when this is happening and I can't capture the ports the connections are eating up since the server crashes milliseconds after the connections begin to open.
What I'm looking for is some strategy or approach I could use to identify where these connections are suddenly coming from.