If everything appears to be normal, there’s a few ways we can setup a cluster that would provide you with better reliability. Both are a little complex, and will take a little time to setup properly, and ideally, once setup, you need to work on optimizing NGINX, PHP-FPM, and MariaDB, otherwise moving to a setup like this isn’t going to provide much benefit at all.
NOTE: Since I don’t know your domain, I’ll be using
domain.com in all examples.
My first recommendation is the more simple way of setting up a cluster that’ll allow you as the need arises, whether it’s vertically or horizontally.
What I would do is separate each concern. You’ve already got a jumpstart on this by offloading your database to its own server, so the concept is very similar.
Setup a load balancer. You can use DigitalOceans’ LB service, or setup NGINX as an LB that you have full control over. You’d point your DNS at this LB and it would handle traffic routing for you.
Setup NGINX + PHP-FPM (using PHP 7.1.x) on it’s own server, much like what you have now. We’d be moving away from HHVM to PHP 7.1.x in this case. HHVM is marginally slower in some areas and marginally faster in others, though ultimately, we’re looking for simplicity and consistency.
Setup Caching Servers, either Memcached or Redis. I’d pick which you’d like to use and setup 2x of them to start. The first one would be used to offload PHP Sessions so that we’re not storing them to files (which is the default) and the second would be for caching that’s handled by WordPress. When you start clustering, this is important as if you ever move to a multi-server setup to distribute content, you need session persistence and that’s not possible using file-based sessions.
Setup a MariaDB Server, much like what you’ve done already. I’d aim for the 10.x release. Right now, we’d setup a single database server. Since you’re not seeing extremely high loads right now, setting up a cluster or master-slave might be overkill.
Bring it Together
How this would work is something like this:
=> NGINX/PHP-FPM => Caching Servers
=> MariaDB Server
The LB handles directing traffic to your NGINX/PHP-FPM instance. Once a visitor arrives, the caching servers come in to play and allow sessions to begin and cached data to resolve. Anything that isn’t in the cache, or can’t be pulled from cache would then hit the database server. On the database server, we’d need to implement some sort of caching as well (i.e. Query Caching) to speed things up there as well.
What this does is simply expand on what you already have and will allow you to increase complexity as needed.
Ideally, for the above setup, I’d recommend the following sizes (these being based off the resource information you’ve provided):
LB => 2GB Droplet
NGINX/PHP-FPM => 8GB Droplet
Caching Servers => 2GB Droplet x2
MariaDB Server => 16GB Droplet
Now, the issue here is that 8GB Droplet for NGINX/PHP-FPM. You’ve stated that you’re using 50% of your current 480GB SDD HD, so the resolution to his would be to use DigitalOcean’s Block Storage option to attach a block device with XXX GB of additional storage. You would then configure WP to use that device, once mounted, for your storage.
WordPress does allow you to change the
./wp-content location/URL, and that’d be set in the
./wp-config.php file, so that’s how we’d manage changing the content locations.
Since you’re only using ~5% of the Web Servers RAM (32GB), which is about 1.6GB, an 8GB Droplet should be fine for it. Since you’re using ~25% of the Database Servers RAM (24GB), which is about 6GB, I’d definitely shoot for the 16GB Droplet as that gives you over double usage and allows room for increased RAM usage from optimization and properly using RAM.
That brings the total monthly cost for the above to around $280 per month. Of course, this is a very basic setup, but we can scale it from there as needed should you find that it’s not coping.
The above setup should provide a better working environment, but optimization is going to be key here, just as much as proper setup is (i.e. firewall, security, etc). This is what I would classify as a starter setup that gets you working more with cluster setups.
You need to make sure NGINX, PHP-FPM, MariaDB and your caching servers are optimized for the work load, otherwise you’ll end up in the same situation.
I’ve setup clusters like these for multiple private clients over the years and they work well, while providing room to grow. They can be a bit complex at first glance, but they do provide better flow and handle traffic far better than a simple two-server setup. Yes, it’s more to manage, though when it comes to scale, these options make such far easier and much less of a headache.