Just use Docker There you can just pull an updated image…
Does docker use
ghost start in the background? If it does then you’ll have the issue
No it doesn’t. It uses node directly.
Has this returned?
I updated my droplet to Ubuntu 20.04 without any problems. But now when I try to update Ghost, I get the memory error as described in the thread linked above.
Also similar, the
--no-mem-check flag works.
Can you share the output of
free -h? We haven’t received any new reports for this. Ghost still requires 150MB free to start
Can you also share your Ghost debug info?
Thanks for getting back to me.
free -h is:
_____total used free shared buff/cache available
Mem: 981Mi 734Mi 69Mi 1.0Mi 176Mi 99Mi
Swap: 0B 0B 0B
Next I’ll try
Based on the output of
free, I’m inclined to think that you were legitimately low on memory…
can you try running
free -h and then immediately running
ghost restart to see if ghost complains about memory?
free + buff/cache >= ~150MB Ghost should not complain, but there are times where the buff/cache is not accounted in the lib.
ghost run should only be used for debugging since there is nothing to restart the Ghost process is if it crashes, and it won’t be running under the correct conditions.
Thanks for your help.
free -h and then
ghost restart without complaints.
I then tried
ghost update and got the same message (low memory).
How much memory does it say you have free?
It looks like you have ~77.87890625 MB available.
I’m not sure if it’s a best practice or not, but adding a 2GB swap file and adjusting the swappiness to 10 solved this issue.
More info here.
FYI: I think that this should be split into a separate issue, but I didn’t see a way to do that. @vikaspotluri123, is that possible and necessary?
Although the memory warnings have stopped with the larger swap file, I used
top to find out what processes are running. The culprit was
mysqld, so I logged into the database and looked at the process list.
I have four processes running but I only have two Ghost instances, so I assume that these are unnecessarily doubled, correct? The processes are:
| Id | User | Host | db | Command | Time | State | Info |
| 29 | [user-12] | localhost:50440 | ghost_production | Sleep | 1113 | | NULL |
| 31 | [user-12] | localhost:50446 | ghost_production | Sleep | 1138 | | NULL |
| 43 | [user-34] | localhost:50510 | domain_com_prod | Sleep | 84 | | NULL |
| 45 | [user-34] | localhost:50530 | domain_com_prod | Sleep | 84 | | NULL |
If I’m correct to assume that I should only have one process per site running, how do I (safely) kill two of the above and never have them reoccur?
It might make sense that there are 2 ghost processes because there’s the
ghost run process which performs validation (and is relatively lightweight), and the actual Ghost process itself. ref
@ScottSemple those are database connections not outright processes, it’s expected that there are at least 2 per Ghost instance because Ghost uses connection pooling to prevent requests being blocked waiting for database queries to finish. The number of connections will grow under heavier traffic then fall back down to 2 with low traffic.
Database connections are fairly light weight on their own but may have query caches using memory if that memory is freely available. If you have a particularly large site then the mysql memory usage as whole would be higher as more of the database is kept in memory to keep things running smoothly.
You can optimise mysql memory usage for lower-memory systems if needed. There are quite a few generic guides for that from a quick google search but you’ll need to understand your system usage and where potential bottlenecks are based on your specific requirements to avoid causing performance problems.
Thanks, @Kevin. That’s good to know.
Both blogs are small with little traffic. I never had any memory warnings until I upgraded Ubuntu to 20.04. Then I regularly got the sub-150MB warning from Ghost. It never warned on
Increasing my swap file to 2GB got rid of the warnings, but usage is still close to 1GB. I haven’t been able to figure out why.
@ScottSemple Having this exact same issue on Ubuntu 22.04 while upgrading to latest release of Ghost 4 (in prep to jump to v5). Has anyone figured out why memory usage has gotten so high on these version of ubuntu, and how to avoid it?
The check being discussed here is checking how much memory is free on the OS, not how much memory Ghost is using. It’s possible something else besides Ghost is using more memory. Use
htop or a similar tool to review which processes are consuming your memory.
Thanks. I actually did look at this, and it’s mysql/mysqld hogging memory. For me, adding a 2GB swap solved the problem. I’m really just curious if anyone knows why mysql 8 & ubuntu 20/22 have this issue in the first place (the issue being far higher memory usage from mysql).
There are some tips here on tuning MySQL to reduce the memory use. I have not tried them myself.