

Ask HN: How to scale 1 server : 1 customer model? - pythoncall

Hi guys I need some help figuring out this pattern.
I have a web application currently running on flask at site.com
for each of my customer, I want to have a droplet from digitalocean running the copy of the flask app.<p>I want to consolidate them under a subdomain like customername.site.com<p>so when they go to customername.site.com, the ip points to their own server.<p>Now the problem I have is handling cases like:
user logs in at site.com, needs to be logged in at customername.site.com
user logs out at customername.site.com, needs to be logged out at site.com
how do you configure an encrypted password for a new droplet instance?
how do you update all droplets with updated code?<p>The reason I have one user per one droplet is because they run cpu and network intensive background jobs in parallel. I don&#x27;t want them to interfere with each other.<p>I guess I&#x27;m trying to achieve horizontal scalability, by just cloning an instance of my original web application, instead of trying to force everyone on the same instance.
Any suggestions or feedback would be very useful.
======
chatmasta
You're making it way too complicated. You only need one flask app. Here's how
you do it:

1) Build the app so it's able to generically handle any request by parsing the
subdomain from the URL (google "flask multiple subdomains" for plenty of
solutions to this)

2) Install the app on one droplet at first, and more as you need to scale.

3) Create a wildcard A record in the site.com DNS (* .site.com), with round
robin load balancing between the IP of each of your droplets. e.g. If you have
one droplet at 1.1.1.1, one at 2.2.2.2, set "* .site.com" to round robin
[1.1.1.1, 2.2.2.2].

This should take care of your scaling for a while. You're severely
overestimating how rapidly you will need to scale. Start with one small
droplet, add to its resources when your traffic grows, and then once it's
maxed out, go to the DNS round robin method.

Further down the line, you can replace those app servers with something like
HAProxy to load balance between them, or do more fine grained load balancing
than DNS round robin.

