How to setup shared storage on DigitalOcean load balanced droplets

I have a WordPress site that periodically peaks in traffic, this does not happen often enough to warrant a beefy server. So I was planning on setting up a load balanced cluster of small droplets.

One problem rose though, how do I keep files synced across the multiple replicated servers, there is no master and slave here. I thought of using a tool like rsync, to keep files in check, but I don’t think this will work in this use case! If one session file got to the other server a little bit late, the user will find himself logged out, user uploaded files on one server might take longer to get to the other than it takes for the user to refresh the page.

So I’m feeling like this is not the right way to go about it.

One solution that I came across, is shared storage, but the block storage supported by DigitalOcean can only be attached to one server.

Is there a setup, where load balancing will ONLY use the other servers purely for their CPU and RAM, if I’m not mistaken, Nginx as a load balancer should work this way, right? Or do I still need to host my app files on all servers in an Nginx cluster.

Please advise.

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.

Hello, @ALKateb

I would refer to this previous question posted on the DigitalOcean community:

Where the following solution was posted:

"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:

I first pointed my domain to wp1 IP I then generated a letsencrypt (cert only) so that I would have the cert info I needed. Then I added this info manually from the files certbot generated to the load balancer Then I pointed my domain to the load balancer, force all traffic to SSL, and connect to port 80 of my droplets behind the load balancer For naming my WordPress servers:

I called one of them and the other I manually added entries in the otherwise identical wp-config.php file on each server with the following: define('WP_HOME',''); define('WP_SITEURL',''); I exclude wp-config.php from my lsyncd setup btw, and sync everything else in /var/www/html For the DB, both wp1 and wp2 point to the same (third) server ( and serve the identical info."

Also you can check this article as well. It’s great!

Let me know if you have any questions about the setup. Alex