MySQL Usage Limit

It usually happens on a server to have high load for no apparent reason. My experience have shown that most of the times this high load is due to badly written SQL queries which cause MySQL to use all available resources for lots of time. This also causes an an excessive number of connections as the queries never end so each new site user creates a new SQL connection.For this reason I have written the attached perl script. I have used code portions from several other scripts that i used to have on my servers. The script creates a PerlĀ  daemon which runs every one minute and checks MySQL process list. It then kills any SELECT queries that are in the execute state for more than 60 seconds. Finally it counts the total number of connections per user and if they exceed 5 it kills them all.

I would be very satisfied with your comments, suggestions and contributions.

Here is the script: mycheck

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.