Load Balancer + Wordpress

I have a Droplet where i have a wordpress + MariaDB + Nginx instalation, i would like to implement load balancing . Any one can give a hint?

Submit an answer

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!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.


I’d be happy to help :-).

When it comes to load balancing, there’s more that comes in to play than just the load balancer. You need to think more about how you want to go about separating things out.

Ideally, in a cluster, you’d separate NGINX + PHP, Database, and Storage in to their own clusters. The reason for this is because you won’t be able to deploy a load balancer, add your existing Droplet + a new one and things just work – there’s some degree of manual work required.

Ideally, you’d setup a load balancer and X number of web servers which will have NGINX and PHP installed (PHP-FPM). We’ll start with 2 in this example, which would look something like:

- Load Balancer
- - Web Server 01 (NGINX + PHP-FPM)
- - Web Server 02 (NGINX + PHP-FPM)

The next cluster we’d need to configure would be storage as we need somewhere to store data so we aren’t having to replicate data across the web servers. For this, most will recommend GlusterFS.

GlusterFS is setup with a client and then Y number of storage servers. It all depends on what you’ll need for your installation. The client is the one you connect to and mount on the Web Servers – it then serves data from the storage servers in the cluster.

So our modified cluster might look something like:

- Load Balancer
- - Web Server 01 (NGINX + PHP-FPM)
- - Web Server 02 (NGINX + PHP-FPM)

- - - GlusterFS Client
- - - - GlusterFS Storage Node
- - - - GlusterFS Storage Node

You would, for example, mount the GlusterFS client on /home on the web servers and that’s how NGINX would pull data to serve requests. It works just like /home does now, except it’s being served from the GlusterFS cluster instead of the physical web server.

The last thing you’d want to setup is a database server. You could set MySQL/MariaDB up on one of the web servers, though it’s generally recommended that you setup a database only server and then connect over the private network from your application.

As you can see, it can get a little complex and this is certainly just one example, though it’s more so tailored to WordPress and database driven applications.

You could certainly run fewer GlusterFS servers, though generally you want to at least run one client and one storage node.

That said, whether or not I’d go this route depends on your traffic. If you’re not at least half way to the point of needing a load balanced solution, I’d start small and work your way up.

There’s a lot that can happen and you would need to be able to troubleshoot – or ask questions here in the community / submit a support ticket for guidance.

If you’re not sure how to go about setting everything up properly, I would definitely recommend hiring a sysadmin to do it for you as a load balanced solution won’t perform any better if it’s not configured properly. It could potentially perform worse or not at all.

Let me know if you have any other questions, always happy to help :-).

How many nodes do you have with glusterfs? Are you running your cluster properly and is it config’d properly? I can shut one node down without any effect on my sites. I can shut two down and get a tiny bit of lag under heavy load but no delay at all still. What version of gluster are you running?

I have a question about the sticky session on load balancer. I have turned it on in my load balancer but when i logged in my wordpress site via loadbalancer ip, and then refresh the page, it will kick me out of admin dashboard (cause the request switch to other droplet), it does not keep my session like sticky session said. Is there any solution for this problem?