On my VPS server, I have a few websites hosted. Suddenly I am facing a connection timeout error. With the top command, I figure out the mysql database using 100% of the CPU. How can I find out which website causing the problem?
List all the database processes by running the following commands:
SHOW ENGINE INNODB STATUS\G;
SHOW FULL PROCESSLIST;
You can also check which MySQL users are logged in. Maybe you will find a specific user overloading the system.
SELECT SUBSTRING_INDEX(host, ':', 1) AS host_short,
GROUP_CONCAT(DISTINCT user) AS users,
COUNT(*) AS threads
FROM information_schema.processlist
GROUP BY host_short
ORDER BY COUNT(*), host_short;