Question

One Django App for Multiple Different Customers

Posted November 16, 2021 63 views
PostgreSQLDjangoDigitalOcean Droplets

Hello,
I have a django app deployed in DO. Currently I have 3 customers, so I created 3 different droplets. Its ok for now but I may have another 3-4 customers signing up in next few days and I expect it to grow 3-4 customers every month. I would really appreciate if someone could help me to figure out:

  • Everytime when i have a new customer, Just take snapshot of one of the existing droplet and deploy that snapshot to new droplet and just change server_name in nginx file. Does it works? Currently everytime I have a customer i follow this https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04 . There should be some easy way as it’s same app with same database structure (Postgress) just for different customer

  • Most of my customers aren’t using all the resources. for example my each droplet has 1TB data transfer and max data transfer i am using in last 3 months is 2GB. I have 3 droplets and in a billing it says you have used 2GB of 3000GB data last month. I read that i can host multiple django in one droplets, should i consider this approach?

  • I think any option I select from above, at the end i have to to git pull, restart server for each project. Is there any better alternatives that i can just to git pull, django migrate in a single place. (I am also looking at django-tenant)

I would really appreciate if anyone could direct me or let me know what should i look for or read for.

Thanks

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.

×
Submit an Answer
1 answer

Hello,

Having each customer on a separate Droplet has its benefits so that if one server has issues, not all of your customers would be affected but just one.

Taking a snapshot of the server and then spinning up a new Droplet based on the snapshot is a good approach, alternatively, you could use this 1-Click Django installation here:

https://marketplace.digitalocean.com/apps/django

Also, you could host multiple Django applications on the same server by using separate Nginx server blocks for each application.

For more information on Nginx server blocks and how to set them up you can follow the steps here:

https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-server-blocks-virtual-hosts-on-ubuntu-16-04

Regarding Django multitenancy, I could suggest taking a look at this GitHub project here:

https://github.com/citusdata/django-multitenant

Hope that this helps!
Regards,
Bobby

by Justin Ellingwood
When using the Nginx web server, server blocks (similar to the virtual hosts in Apache) can be used to encapsulate configuration details and host more than one domain off of a single server. In this guide, we'll discuss how to configure server blocks in Nginx on an Ubuntu 16.04 server.