Trying to figure out how to setup my droplets

Hi all, so this is my first time asking anything here. Actually, its my first time using DigitalOcean at all and I’m sort of confused about how I should be setting my stuff up.

Here’s the thing, I am building an API service for my mobile app. It will be a REST api and the server will have MySQL and PHP. So when creating my droplets, I have scalability in mind and so I noticed that DigitalOcean has cool stuff called Load Balancer to handle the traffic better between my droplets.

My question is this: I’m going to have two databases, one to have logins and the other to have data which I will serve to the user. Now, lets say that I have two droplets and I’m using a load balancer as well, how would my database will be setup? If I have droplet1 with all my data then I’m guessing I need to create an image out of it and use that for my droplet2 and this way the data between the droplets will be exactly the same, is there another and more dynamic way to do this?

And then lets say that I do create two droplets using the same two image with same exact data but then how will the data going to sync later in the background? The issue I see is that the user starts the app and that connects to droplet1, in which the user will be marked logged in and then when the app continues to progress the second or third call to the server might be made to droplet2 and the login table in that droplet does not have the user marked as logged in and will return empty data set.

I would really appreciate any help, thanks in advance!


Submit an 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.

The load balancer is for HTTP(s) only. It doesn’t do DB LB. So you’ll need to be able to sync data between the two DBs. Master-master replication is your best bet. Here’s an article to read: