One droplet running web app snapshot for each customer?

June 25, 2014 786 views

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.

I want to consolidate them under a subdomain like customername.site.com

so when they go to customername.site.com, the ip points to their own server.

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 customer droplets with new code?

The reason I have one user per one droplet is because they run cpu and network intensive background jobs in parallel. I don't want them to interfere with each other.

I guess I'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.

1 Answer

In order to deal with the login use case, you could use OAuth. site.com would be the OAuth provider with the customername.site.com sites as consumers. Check out Flask-OAuthlib.

A different approach might be to have site.com act as the front end for all users, but have a scalable backend. That way all of the long running, cpu and network intensive jobs will actually be running on different servers, but the user would only login to the frontend.

As for updating all customer droplets with new code, I'd suggest you look into git hooks. You could setup a git repository with a post receive hook to pushes to each server. You could also use something like Fabric to do automated deployments.

by O.S. Tezer
In this DigitalOcean article, the system administration and application deployment streamlining library "Fabric" is our subject. We will learn how to install this wonderful tool, as well as see how easy things can become by simply automating mundane management tasks that would otherwise require jumping through hoops with bash hacks and hard-to-maintain, complex scripts.
Have another answer? Share your knowledge.