Solving the MySQL Sleeping Processes WordPress Issue

Few days ago the WordPress installation on DevMD was constantly giving MySQL problems like unable to connect, connection to database lost which made the site unusable. After a quick look at the MySQL process list I saw that there were more than 300 sleeping processes which was the server limit for the account. Although the processes should die after 30 seconds, something was managing to create enough load on the site to quickly take all the available processes.

The first thing I did was to try to disable and delete all the unused plugins, change the MySQL config and reinstall WordPress, but none of that helped. Since the site is not getting that much traffic it was not the most logical thing to do, but with WP it is the first step to take.

It was a time to investigate a bit further. Next were the server logs which revealed the source of the problem, thousands and thousands of XML-RPC requests were being thrown at the server from a lot of different IP addresses. Since I did not use the XML-RPC WordPress API, I had disabled it with a plugin, which honestly did what it was supposed to do but still WP was making the database connections thus creating the sleeping MySQL process issue.

The solution turned out to be quite simple, adding one line of code to the xmlrpc.php WordPress file, just right after the opening PHP tags I added exit(); and the problem was solved.

I hope my experience and the case described here help someone facing the same problem as I did with my WordPress site.

Category : PHP
Tags : , ,