[Fixed] Ghost Blog crashing on Digital Ocean Basic 1 GB Droplet

[Fixed] Ghost Blog crashing on Digital Ocean Basic 1 GB Droplet
Fixing Ghost Blog crashing on Digital Ocean Basic 1 GB Droplet

If you are facing issues of your 1GB droplet randomly crashing or seeing memory spikes just before the server crashes. This article will help you to fix the issue of your droplet crashing randomly. I have implemented the same fix to my self-hhosted blog on Digital Ocean 1GB droplet. Below is a step-by-step guide to fix the issue.

I was using WordPress earlier but decided to migrate to Ghost CMS for my website (blog.electroica.com) and 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 a "downtime" notification to 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 Basic 1 GB RAM droplet

Do not upgrade if you have low traffic, just add a swap memory, tutorial on how to add a swap memory safely is below.  

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.

[FIX] 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.

P.S. use an uptime monitor to track your site status.

UptimeRobot: Free Website Monitoring Service
Start monitoring in 30 seconds. Use advanced SSL, keyword and cron monitoring. Get notified by email, SMS, Slack and more. Get 50 monitors for FREE!

Originally posted on DesignZig

Loading comments...