You may be wondering, what is “high availability” and why do I need it? The short version is the ability to stay online beyond a single point of failure. Whether it’s a single server spiking, the database getting clogged up with connections, or running out of memory, having a self-healing and scalable environment. (more info at digitalocean.com)
This tutorial will walk you through how to set up an auto-scaling and self-healing configuration for WordPress.
Running a highly available WordPress cluster can be challenging. I have worked through many of those challenges to build, what I think, is a stable and resilient cluster of servers to manage and serve WordPress.
I will be using the following services from Amazon Web Services (AWS).
- EFS (Elastic File System)
- RDS (Relational Database Service)
- ALB (Application Load Balancer)
- (optional) Lambda + Cloudwatch
In additional, we’ll be using Cloudflare for it’s CDN, WAF, and SSL. I personally find it more cost effective than using the AWS-native CloudFront. CloudFront is not bad, just more expensive than the standard base package of Cloudflare (which is free).
After following this tutorial, you will have a vertical and horizontally scaling cluster of servers to serve WordPress. It will be a single instance for the backend (wp-admin, aka WordPress dashboard), auto-scaling servers for the frontend to handle all user load, and a central cache system using Redis via ElastiCache.
First step, you’re going to need a domain. If you don’t have one, I personally use Namecheap, and have been for 10+ years.
Next step, setup your Cloudflare account. The Free account is perfectly fine for what we’re doing, but by all means, the next step up for $20/mo is still a steal for what it offers.
Next step, setup your AWS account. Note that this is a different account than any amazon.com shopping account. You can absolutely use the same e-mail address for this account. After registering and setting up, I strongly recommend enabling 2 Step Authentication to better secure your account. Amazon calls it “Multi-Factor Authentication” and I use the Google Authenticator iOS app to store my two step credentials.
After setting up your initial account and going into the AWS dashboard, you have the important decision of which datacenter you want to run in. I chose the Oregon region. Once you have selected your region, it is a good idea to regularly check that you are in the desired region when making changes — or you may not see everything you were expecting. This toggle is found top right of the dashboard.
Let’s get into the meat of actually setting up our highly available environment.