Question

mysql is using 100% cpu and causing establishing database error

my droplet: 4 GB Memory / 80 GB Disk / BLR1 - Ubuntu/ wordpress/ woo commerce I’m getting database error every 2 hour, sometime i can resolve it by restarting the droplet, and sometime i need to restore a backup funny thing that sometimes i don’t do anything and the matter is resolved by itself, but i lose my custom css…i have no idea what is the relation here! but when database error happen, i see that cpu usage is above 100% and i run mysql-tuner and got: [!!] Maximum possible memory usage: 9.9G (257.48% of installed RAM) [!!] Overall possible memory usage with other process exceeded memory

I need help in fining out the solution for cpu 100% I need help in configuration of my.cnf for my droplet: 4GB/ 80GB


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Accepted Answer

Hi there,

I would suggest a few things:

  • Try following the steps from this tutorial here on how to tweak your MySQL server for better performance:

https://www.digitalocean.com/community/questions/how-to-tweak-mysql-mariadb-configuration-for-increased-performance-and-stability

  • Add a caching plugin for your site so that it would make fewer requests to the database itself.

  • Use a CDN service like Cloudflare to make reduce the overall work that your server has to do.

  • Consider switching to a Managed MySQL database which is optimized for you out of the box:

https://www.digitalocean.com/products/managed-databases-mysql

Let me know if you have any questions!

Best,

Bobby