Question

Small Ghost website, memory use at 80%! What is wrong?

Hi everyone - here’s my top-level situation:

I’m running a small portfolio website and blog, with daily traffic in the low dozens. I use Ghost [4.32.0] on a Digital Ocean Droplet (Ubuntu 20.04.3 LTS (GNU/Linux 5.4.0-99-generic x86_64))

I have two external issues:

  1. my website seems to go offline sporadically - once a week - and I get a bad gateway error until I go into my console and reboot the server.
  2. I am currently unable to upload images to my blog through the Ghost CMS. When I try, I get this error:

“Service was unreachable. Retry”

Now, when I go into my Digital Ocean graphs, I see that my memory usage is running persistently at over 80% - sometimes up to 85%. It never drops below 78% This doesn’t seem right for a small website serving such low traffic.

Digging deeper, running <code>top</code> I find that MySql is using the bulk of the memory.

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
759 mysql 20 0 1343800 466616 18904 S 0.7 46.6 1:52.67 mysqld

When I run <code>service mysql status</code> I get the following report:

● mysql.service - MySQL Community Server Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled) Active: active (running) since Mon 2022-02-14 16:47:25 UTC; 21h ago Main PID: 759 (mysqld) Status: “Server is operational” Tasks: 47 (limit: 1131) Memory: 463.5M CGroup: /system.slice/mysql.service └─759 /usr/sbin/mysqld

I have tried <code>service mysql restart</code> and it makes no difference. I have also tried to switch off my droplet and then switch it on and it makes no difference.

I also ran mysqlTuner and it flags the following:

[!!] Maximum reached memory usage: 834.8M (85.45% of installed RAM) [!!] Maximum possible memory usage: 9.9G (1036.23% of installed RAM) [!!] Overall possible memory usage with other process exceeded memory [!!] name resolution is active : a reverse name resolution is made for each new connection and can reduce performance [!!] Ratio InnoDB log file size / InnoDB Buffer pool size (75 %): 48.0M * 2/128.0M should be equal to 25% General recommendations: MySQL was started within the last 24 hours - recommendations may be inaccurate Reduce your overall MySQL memory footprint for system stability Dedicate this server to your database for highest performance. Configure your accounts with ip or subnets only, then update your configuration with skip-name-resolve=1 Before changing innodb_log_file_size and/or innodb_log_files_in_group read this: https://bit.ly/2TcGgtU Variables to adjust: *** MySQL’s maximum memory usage is dangerously high *** *** Add RAM before increasing MySQL buffer variables *** innodb_log_file_size should be (=16M) if possible, so InnoDB total log files size equals to 25% of buffer pool size.

======

The only other thing I can think to try is to update my version of Ghost - but there’s not enough memory to carry out the upgrade! I am reluctant to buy more memory - simply because a website this small with such low traffic shouldn’t need it.

So my questions: is there anything that could be causing my small, lightly used database to be churning so much memory? Is there an obvious solution beyond deleting the droplet and starting from scratch?

I hope I’ve provided enough information - I am a newbie so I might have missed something obvious. Any guidance would be much appreciated!


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.

Hi there,

From the output that you’ve shared it looks like that you’ve increased the MySQL memory too much. MySQL is set to use 10GB of RAM but you only have 1GB of available RAM, meaning that MySQL is trying to use 1036.23% of installed RAM.

You need to make sure that the MySQL values that you’ve set in the my.cnf file do not exceed the actual available memory.

I would suggest running the MySQL tunner again, and using the values that the tool suggests.

Once the MySQL config is correct, you might also consider adding some extra RAM to your server in case that the high memory utilization continues.

Additionally you could add a 1GB swap file so you could have some extra buffer:

https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-20-04

Let me know how it goes.

Best,

Bobby