Tuesday, July 21, 2009

Get rid of mysql sleep process/connections

Some times there are many many sleep processes in your SQL connection. These sleep connections consume a lot of resources (RAM, cache and processor). This can cause you mysql server slow down. If your mysql server is not responding then the query to the database will take a lot of time. In such situations, your website will open very slowly.

This is really frustrating for webmasters. Here, I will show you how can you get rid of these sleep processes.

What is sleep process and Why are there too many sleep process in mysql?

Sleep process are the connections waiting for new Mysql query. This can happen if the database connection is not closed properly. Or you are using mysql_pconnect() command in your php script.

$vi /etc/my.cnf

And add this line in my.cnf

wait_timeout = 60

No comments: