Hi,
By using LAMP image from Digital Ocean, I manage to have a simple PHP web application (for production usage) in droplet, with 0 package installation.
As time goes on, I plan to develop more web application in Python (for production usage too).
I read through https://www.digitalocean.com/community/tutorials/how-to-deploy-python-wsgi-applications-using-uwsgi-web-server-with-nginx , it seems that using virtual environment is highly encouraged.
I was wondering, if I plan to have multiple web applications, should I have multiple droplets (without virtual environment), with each droplet will host 1 web app.
Or, should I have single droplet, with multiple virtual environments?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
The simple answer is to use multiple droplets.
The longer answer is, it depends - there are lots of approaches to this. We can get pretty far down the DevOps rabbit hole on this question. (And apologies if I’m explaining some things you already know.)
You’ll want to isolate your applications from each other as much as possible, but there are many ways of doing this. That article mentions Python’s virtualenv tool, which isolates Python’s library directories per application, but your application could still write over some file another application was using, etc. Multiple applications could live side by side without problems, but the trend in server application development these days is to isolate them so you don’t have to take that chance.
So, multiple droplets is one way of doing this. In that case, I would recommend looking into tools like Ansible (or Chef, or Puppet, etc…) to allow you to set up a machine the same way every time with just what that application needs.
Another way of isolating applications is running them in Docker containers - which you can think of like little application-focused virtual machines running along side each other on your droplet.
Both of these approaches require learning a bit of tooling, and some processes to get them right for production-level deployments, and each have their pros and cons. If you’re a beginner, working on applications that aren’t going to be large-scale deployments - I’d say that you’ll probably be fine with whatever you choose. But the more isolation you can get (with either approach), the less headaches you’ll have down the road.
Thanks. I first thought virtualenv is similar to vagrant / docker, but I only realize they are completely different stuff till I finish setup yesterday.
Will go for single droplets and multiple vagrant / docker approach at this moment, for cost consideration purpose :)
Heya,
Both approaches—multiple droplets for each app and a single droplet with multiple virtual environments—have their pros and cons. The right choice depends on your specific requirements, the scale of your apps, the expected traffic, and your budget. Let’s look at the advantages and disadvantages of both approaches:
Advantages:
Disadvantages:
Advantages:
Disadvantages:
Small Projects: If you’re just starting or if these are small projects with low traffic, start with a single droplet and use virtual environments. It’s cost-effective and should be sufficient for initial stages.
Mission-Critical Apps: If one or more of your apps are mission-critical or expected to have high traffic, consider giving them their own droplet. This provides better isolation and allows for more specific scalability.
Diverse Requirements: If the apps have significantly different system-level requirements, it might be simpler to use separate droplets.
Backup and Monitoring: Regardless of the choice, ensure you have proper backups, monitoring, and security practices in place.
In the end, there’s no one-size-fits-all answer. Start with what makes sense for your current situation, and as your projects grow and evolve, you can always migrate and restructure as needed.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.