High memory usage on digital ocean droplet by mysql 8

You may start with

https://www.techolac.com/linux/how-to-optimize-apache-mysql-performance-for-1gb-ram-vps-centos-rhel/

Good advice for a low memory instance..and tuning mysql down.

Be advised, that you will loose performance, so understand where your bottle necks are.

If you have massively complex queries, the optimise your database.

You might even very simple queries, and you can use an entirely different database server instead , such as a NOSQL database.

So not only think about tuning your server, but look at code running on it, and perhaps optimise your code too.


An operating system will use all the RAM for cache - cache can be freed almost instantly and helps performance. So RAM available generally isn't important, it's freeable memory that's important.

From the info above:

  • 612.3 used
  • 279.5 buffer / cache
  • 89.5 free

You actually have 297 + 89 = 386MB available for use.

I have MySQL, PHP, Nginx, and a few utilities running on an AWS server with 512MB RAM and 512MB of swap, so it's possible. I made a six part tutorial which is probably a bit out of date now but could have some useful tips.

From memory the key things to do are:

  • Disable the MySQL performance schema as this hugely reduces RAM usage, and set up parameters that suit your system (tutorial for MySQL 5.6)
  • Limit the number of PHP threads, and limit the RAM they use to only what they need. PHP uses huge amounts of RAM.
  • Add a bit of swap, just in case your run out of memory. The OS will push anything it doesn't really need all the time out to swap even if it has enough RAM.