High cpu usage by sql processes, whm


I am obsessed with my server performance. I like tracking processes to see what is taking a high load on my server and try and fix. For some reason my server has been having a very high load caused by mysql processes. I did some research and the following seemed to work.

Login as root to your server via SSH

  • Run the following command: /usr/local/cpanel/3rdparty/mysqltuner/mysqltuner.pl. This will give you suggestions of sql to append to your sql config file.
  • go to /etc/my.cnf to add the results above. If the suggestion was > or >= make sure to modify the suggestion accordingly. i.e: if the suggestion was “max_heap_table_size ( >10M)” you change that to something like “max_heap_table_size = 20M” .
  • Now optimize your database by running the following command: mysqlcheck -u root -p –auto-repair –check –optimize –all-databases
  • restart mysql: /etc/init.d/mysql restart

If your sql failed to restart, it must be one of the new configuration you appended. I would try to get rid of the “table_cache: and “innodb_buffer_pool_size” first to see if this resolved the issue.

Always backup your old configuration in case you have to roll back.

This is not a guarantee that your load will go down, but it is a good start.