How does a DigitalOcean Load Balancer keep databases in sync?

April 5, 2019 349 views
Load Balancing WordPress DigitalOcean Ubuntu 18.04

Say I have a Wordpress blog that is getting so much traffic.
So much so, that my Apache server cannot keep up with the requests.
To mitigate these timeouts due to large numbers of requests, I look at a DigitalOcean load balancer.

What I would like clarification on, is if I have 3x $10 droplets of the same setup, and 1x Digitalocean load balancer distributing the traffic between the 3, - if I simply go to my website and write a blog, presumably my requests are handled by 1 of the 3 servers , my question is this: how does DigitalOcean's load balancers ensure that the MySQL databases holding Wordpress post and user data, keep everything in sync?

If I write a post or create a new user on "LON1-001" server , does the loadbalancer update "LON1-002" and "LON1-003" servers? Apologies but I am new to load balancing.


1 Answer

A load balancer would be setup to distribute the incoming request for your website to the three web servers that you mentioned.

In this kind of a setup, you would want to separate out your Database so that it isn't running on any of the web servers and instead move it to a separate droplet, that is just running the DB alone.

Then each of your web servers would have their own credentials to connect to your MySQL instance running on the Database droplet.

This way when you distribute your HTTP traffic to each of the webservers, they are all accessing the same DB and that is where content is kept in sync, because it is a single database that is reading and writing data for the three web servers.

Have another answer? Share your knowledge.