WordPress Crashing in Digital Ocean VPS Droplet

November 9, 2014 9:24 pm Leave your thoughts

451I’ve been building a hobby blog for a while now using Digital Ocean as the host. I think they are one of the most affordable and user friendly VPS around, when I started playing around I was using their┬ápromo link for a $10 which covered 2 months of free VPS on their most basic instance.

The basic plan actually have decent disk space and the only real limitation was the RAM, which I thought should be enough to run a simple blog. The blog is released now and it’s called Giant Robot Movies by the way, just one of my interests on my free time.

A Simple Blog

In order to┬ásave some time I was using a pre-build theme, which I was going to customise. The theme’s codes looked alright, with heaps of ability to customise the appearance and behaviour without changing the code at all.

Knowing the limitation of the basic plan, I opt to use a lot of caching on the website. One of the caching mechanism that I am using is memcached, which means that each page should be cached in-memory for quite some time, until the next cache clear or content update. This works well in my local development environment as well as the server. However when I started browsing around a bit more and adding more posts (this is all happening before release by the way), the server started to get slow and require restarting.


I was wondering what’s happening with the server, it’s only running one blog with only one user. The website wasn’t doing any sophisticated things, only serving images and information. I started looking at the server performance and disk space. What I noticed was that the CPU load was high but not 100% of the time, but MySQL was working quite heavily.

The frontend would stall after a few reloads and there will be a database connection error displayed. After each server restart it would work but then it would die out again. One of the error messages that leads me to the solution was “InnoDB: Fatal error: cannot allocate memory for the buffer pool”. It seems that the server was constantly running out of RAM serving static blog contents.


The solutions to this problem, which seems to be holding out just fine are the following:

  1. I changed the wordpress theme to a simpler theme, which I then optimized more. This is definitely the main fix. The theme that I was using was great with lots of customizations but it seemed to be using too much memory.
  2. I enabled swapping on the VPS instance. Digital Ocean droplets do not come with swap capabilities out of the box, perhaps for good reasons. However to avoid the server dying out completely, I have added some swap space just to be sure.

    In addition to the above commands I have also make sure that the swap file is always loaded on boot. In the file /etc/fstab I have added the following line:

    I then adjust the swappiness of the OS to control how “willing” the OS wants to use its swap. Too much won’t be good and too little won’t do any good at all as the OS won’t even use the swap. Here are the configurations that I use, I think it’s a good balance for Digital Ocean VPS.

Doing the above two things as well as leveraging on caching and CDNs has helped me brought out a hobby website quite well. I hope that this helps people who just started using Digital Ocean as well as those who wanted to bring out blogs such as my GiantRobotMovies out there.

Tags: ,

Categorised in: ,