James Bachini

High CPU usage on mysqld but low memory usage

Had a problem with a server that was running alot of traffic and doing a lot of logging and updating mysql tables. The CPU usage was through the roof and it’s an 8 core server with 30GB of RAM. The strange thing was that mysqld was using all the processing power but hardly any memory was being used.

You can check what is using all the CPU/Memory by running “top” from the command line. Ctrl-C to exit.

A quick fix to balance out the load was to add the following line to /etc/mysql/my.cnf    (might be /etc/my.cnf on alot of servers)


20GB stands for 20 gigs of RAM so adjust this to suit your hardware specs. A rule of thumb I read was to use 70% of the total RAM but I would suggest using 70% of the free RAM on the system just to be safe, especially if your server isn’t only being used as a database server. So if you have a 4GB VPS with 2GB of currently free RAM use 1.5GB for the innodb buffer pool.

I would imagine this would work the other way round too so if you find RAM stats getting low, lower the pool size to free up memory.

Get The Blockchain Sector Newsletter, binge the YouTube channel and connect with me on Twitter

The Blockchain Sector newsletter goes out a few times a month when there is breaking news or interesting developments to discuss. All the content I produce is free, if you’d like to help please share this content on social media.

Thank you.

James Bachini

Disclaimer: Not a financial advisor, not financial advice. The content I create is to document my journey and for educational and entertainment purposes only. It is not under any circumstances investment advice. I am not an investment or trading professional and am learning myself while still making plenty of mistakes along the way. Any code published is experimental and not production ready to be used for financial transactions. Do your own research and do not play with funds you do not want to lose.