Applicable to:
- Plesk for Linux
Symptoms
- The
mysqldormariadbdservice consumes a great percentage of the overall CPU resources on the server as it can be observed ontop -ccommand's output. - Plesk and its websites may not be accessible or be working slow.
-
Slow long running database queries may be found with the following command as well as under Tools & Settings > Database Process List:
# plesk db "SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST ORDER BY TIME DESC \G;" | grep TIME:
TIME: 455
TIME: 300Note: A normal query is completed in a few milliseconds (for example, 5 to 50 ms). The
TIMEvalue is shown in seconds, so a healthy query is displayed asTIME: 0, while values of several seconds or more, like the ones above, indicate slow queries.
Cause
The MySQL or MariaDB server is not tuned for the server’s resources, or slow queries from non performant customer databases keep it busy, which generates high CPU usage.
Resolution
Note: Database performance tuning is out of the scope of Plesk Free Technical Support. This serves as a general-purpose guide.
- Apply the recommended MySQL/MariaDB settings in Tools & Settings > Performance Booster > Serverwide by following steps 1 to 5 in the Plesk for Linux section of this article
- Only if the high CPU usage persists or comes back, continue from step 3 to troubleshoot specific non performant databases.
- Log in to Plesk server via SSH
-
Identify the slowest queries. A normal query finishes in milliseconds and is displayed with
Time: 0, so focus on queries that run for seconds or longer:# plesk db "SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST ORDER BY TIME DESC \G;"
Id: 4047
User: johndoe
Host: localhost
db: ExampleDB
Command: Query
Time: 300
State: Sending data -
Kill the slow queries by their ID from the previous step:
# plesk db "kill 4047"
-
Identify the subscription associated with the database from step 4:
# plesk db "select d.name from domains as d, data_bases as db where db.dom_id=d.id and db.name like '%ExampleDB%';"
+----------------------------+
| name |
+----------------------------+
| example.com |
+----------------------------+ - Consider to temporarily suspend the related subscription to decrease the CPU load.
- Contact website developers to review slow SQL queries, and share MySQL Performance: Identifying Long Queries and MySQL Performance Tuning as reference guides.
Comments
Please sign in to leave a comment.