Hosting Ghost CMS on Digital Ocean droplet shuts down abruptly.

Read this if you are self-hosting your Ghost blog on digital ocean droplet and facing the issue of droplet shutting down.

Hosting Ghost CMS on Digital Ocean droplet shuts down abruptly.

I am using Ghost CMS for this website (designzig.com) and decided to self-host it on a digital ocean droplet.

Everything was fine until the traffic on the website started to increase. The droplet started to shut down frequently. Thanks to the Uptime monitor for sending "downtime" notification on my email.

What is Uptime monitor: To monitor my site's uptime I use Uptime robot's free plan which checks the status of my website at every 5 mins and notifies me via email if the website is down. I have been using it uptime robot for my other blogs also and it does a good job to keep a check of a website's live status.

Adding Swap to droplet

Investigating the Issue with the droplet

I contacted the digital ocean support center to look into the problem and resolve it. The support was prompt, there was no issue with their server the issue was with my droplet. They asked me to monitor the CPU usage of the droplet and check for processes that are consuming high CPU resources.

It is not a CPU usage problem.

Although the CPU usage spiked before and after the droplet shuts down It is not the real cause of the problem because the CPU usage stays unbelievably low (1%-2%) mostly.

CPU usage graph

It is a memory issue

While googling the issue I came across a similar problem faced by users hosting their website on digital ocean droplets. Some of the answers suggested adding a "swap memory".  

This lead me to check for the memory usage trend of the droplet and Voila I found the issue "The memory" was on fire🔥 100% consistently.

100% Memory Usage graph

Solving the 100% memory issue in Digital ocean droplet

Since there is not much traffic on my website and the CPU usage is low, I decide not to upgrade the droplet and add a swap memory to the droplet.

What is a Swap memory?

Swap memory/ swap files are used in a linux file when the RAM is full, it act as virtual RAM. It is slower than the physical RAM as it uses HDD space.

Adding Swap to Digital Ocean droplet

I used this tutorial on the digital ocean community to create the 3 GB swap file in the droplet.

How To Add Swap Space on Ubuntu 20.04 | DigitalOcean
One way to guard against out-of-memory errors in applications is to add some swap space to your server. In this guide, we will cover how to add a swap file t…

The tutorial is well-documented and I didn't face any issues while following it.

In no time I successfully created Swap space in the Linux system 🥳.

Result after adding Swap memory

After adding the swap memory I haven't observed any downtime or abrupt shutting down of the droplet.

However, there was an increase in the disk usage of the droplet, the reason being the Swap file created on the HDD.

Decrease in memory usage after adding swap space
Slight increase in disk usage after adding swap

So far adding a swap proved to be a solution to mitigate the high memory usage and abrupt shutting down of the droplet.

I hope this helps and solves your problem too.

Loading comments...