Swap On!

My VPS kept freezing the moment I published a Ghost post, and support swore no one else had issues. Turns out MySQL was eating all the RAM on a box with swap disabled by default. So: enable swap, and don't forget the fstab entry so it survives a reboot.

Swap On!
Superhero who brings virtual memory to people in need.

I've never had stability issues with my VPS provider of choice ... until I started using Ghost. As soon as I started publishing posts, the whole VPS would freeze up and I'd have to force reset it. It felt as though if I were gentle with the system, it would remain stable, longer. So weird.

I went back-and-forth with support. I thought maybe the underlying hardware might be at fault. They determined no other VPSs were reporting stability issues. Somehow, they thought to point out that swap is off by default.

Underlying Ghost is MySQL. It would manage to consume all available RAM, at which point everything else stops working, which is entirely expected on a system running without virtual memory.

So, yeah, for future reference, enable swap on your VPS if it isn't already (if you might run out of RAM).

Some links I found with step-by-step instructions for enabling swap, summarized here (mostly so that I can quickly find this next time around):

sudo swapon --show
sudo fallocate -l 1G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo swapon --show

Additionally, don't neglect to add the swap file to your fstab so that it starts at boot:

echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

This post is for members only

Already have an account? Sign in.

Subscribe to A garage sale for your mind

Don’t miss out on the latest posts. Sign up now to get access to the library of members-only posts.
[email protected]
Subscribe