High Availability WordPress with Digital Ocean Load Balancer, GlusterFS, Spaces, Auto Let's Encrypt SSL Renewal, with Cloudflare DNS

October 27, 2018 1.7k views
High Availability Load Balancing Let's Encrypt WordPress Ubuntu 18.04

I'm trying to create a High Availability WordPress instance. These is what I think I need

  1. A Digital Ocean Load Balancer
  2. Two droplets using GlusterFS
  3. Digital Ocean Spaces mounted to offload the uploads directory
  4. Digital Ocean's Spaces CDN enabled
  5. Automatic Let's Encrypt renewal by utilizing the Digital Ocean API
  6. Cloudflare's DNS
  7. At least one database.

From what I was reading, Digital Ocean's Load Balancers handle their own failover which is why I don't think I need a floating IP and two load balancers - please correct me if I'm wrong.

In order to keep WordPress's wp-content directory in sync, I need to use GlusterFS, otherwise, how would I keep the theme and plugin files in sync? What happens if I need to add another node?

To make sure that storage isn't an issue, I want to mount Digital Ocean Spaces to the uploads directory, but I'm confused on how this will affect GlusterFS. I planned on doing this with the WordPress plugin. Will there be problems because there are two backend servers potentially writing to the same files?

I was also thinking of using Digital Ocean's CDN but wasn't exactly sure if this was necessary due to CloudFlare.

I want to automatically renew the Let's Encrypt SSL certificate so I don't have to manually do this everytime it is about to expire, but how do I achieve this? I keep reading that the Digital Ocean API can achieve this but I'm a little confused as to where I should generate the cert and then what kind of script I need to run to update the cert on the Load Balancer.

I want to use Cloudflare for security and caching reasons. Will using Cloudflare's proxy/caching mechanism work on Digital Ocean's Load Balancer?

Finally, I'm confused on what happens with the database if both load balanced servers are writing to the same table entry.

Any help would be appreciated on what I need to do to get this all working. I figured I would go in this order

  1. Create the two droplets with WordPress installed and setup GlusterFS
  2. Create the database on a separate droplet and connect WordPress to the database
  3. Prepare the uploads folder to utilize Spaces & turn on the CDN
  4. Put the Load Balancer in front
  5. Assign the DNS to point to the Load Balancer IP
  6. Begin the SSL cert process
  7. Enable Cloudflare's proxy
4 Answers

Looks like this might be the tutorial I'm looking for: https://deliciousbrains.com/scaling-wordpress-network-filesystem/

Reading more about it, it sounds like I cannot offload the media folder and do GlusterFS at the same time. I would prefer to just use Digital Ocean Spaces but I'm unable to find any information on if rsync is good enough to keep the wp-content folder's in sync.

This may help in case anyone decides to use Cloudflare in front for SSL: https://community.letsencrypt.org/t/cert-for-digital-ocean-load-balancer-cloudflare-dns/75974/9

if anyone is following, everything is working except plugin installation, I'm not sure what is causing this but there is a 504 error being reported by Cloudflare which I'm still looking into.

Hi Tanner,
Did you get the plugin installation issue resolved? I'm looking to do a setup similar to what you've described here.

Have another answer? Share your knowledge.