I have been running my WordPress/WooCommerce e-commerce and membership site happily for a couple of years now all on one server. But my traffic and membership is such that I want to transition to a more fault tolerant setup. I was thinking of the following:
The above setup should be all I need for now, but I have a few questions:
SSL passthrough to each of the WP servers or not? What happens when someone makes a purchase if SSL is terminated on the Load Balancer? Does this all just work seamlessly with authorize.net (or other gateways) or are there some issues there?
Are there specific nginx config or session gotchas in this scenario?
What about server naming? What are the server names in each of the WP servers if they are sharing the same DB? how do I make them different? DO i need to make them different?
Anything else I should be aware of?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Click below to sign up and get $200 of credit to try our products over 60 days!
Enter your email to get $200 in credit for your first 60 days with DigitalOcean.
Well, in case anyone was interested, here is what I ended up doing:
After reading up on GlusterFS, I had a ton of reservations about performance issues for my needs. In short, it is apparently horrible for the multiple small files scenario that my wordpress sites represent, and much better suited to medium to large media files. So instead, I set up lsyncd from wp1 to wp2, and although it is a few seconds delay to copy/sync, it is more than adequate for my needs.
For setting up the load balancer:
For naming my wordpress servers:
For the DB, both wp1 and wp2 point to the same (third) server (db1.mydomain.com) and serve the identical info.
The only issue may be having to clear the cache manually from time to time on each server individually, but I am looking into creating a button/plugin in the wp admin that will clear both servers’ nginx cache at the same time/on the same click. Other than that, I am super happy with the setup! Anyone have any thoughts or critiques of this approach?
This is a great place to start for a scalable WP installation. https://www.digitalocean.com/community/tutorials/automating-the-deployment-of-a-scalable-wordpress-site
A few caveats I have run into / answers to a couple questions
1 - Some issues can creep up with how WP handles itself behind an SSL termination - this is one trip that helped:
2 - I use purely NGINX in my setup(s) so this one also helped out - and yes sometimes some gotchas creep up but not as many as one would thing (in my experience)
3 - Server / Node naming is pretty much up to you and how you would like to design this convention. Some people name their nodes/droplets in a way that it tells them what the machine does, it’s OS, regions etc… (example - u.x.t1.lb-1.domain.com - ubuntu.xenial.toronto.loadbalance-1) others name them after starwars planets or pets.
A note DO does setup PTR records for droplets with names that resolve to their IP address - for example u.x.t1.lb-1.domain.com - add a sub-domain for u.x.t1.lb-1 that points to the domain.com droplet. Something to take into consideration.
Each of your WordPress/Application(s) can access the same DB Server. However in higher traffic situations your DB will become taxed. You could add a Redis Cache Server to your setup to help with this or use use something like the WordPress Plugin HyperDB to spread the database across multiple nodes, or setup a DB cluster - a few choices or combination of choices here. A start - https://docs.jelastic.com/wordpress-cluster
Moving ahead to a more fault tolerant architecture you might want to look at this for your load balancer https://www.digitalocean.com/community/tutorials/how-to-create-a-high-availability-setup-with-heartbeat-and-floating-ips-on-ubuntu-14-04
Another caveat I ran into is keeping each application/wordpress installation in sync with each with assets, plugin/theme versions etc…
The asset(s) aspect could be solved by moving this into DO Spaces - There are many WP Plugins available to help link the space and your media folder up.
As for the application server(s) being in sync, you could move your WP installation into a docker container and store the files on a shared network volume.
Hope this helps