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.
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.
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.
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.
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.
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.