How do experienced web developers deploy Django in production on EC2?

I have never worked for a company that deploys a Django application (with a large user base), and I am wondering if this is the best way to do this.

I am currently hosting a Django application on EC2. The code for the application is in my github account. I have nginx serving static content, and behind it is one Apache server running django + mod_wsgi.

I am trying to figure out what is best for continuous deployment. Right now, after adding extra features, I am doing the following on EC2:

1) git reset HEAD --hard

2) git pull

3) restart apache

4) restart nginx

I have custom logic in the settings.py file, so if I run on EC2, debug gets False, and my databases switch from sqlite3 (development) to mysql (production).

This seems to work for me now, but I wonder what is wrong with this process and how I can improve it.

thanks

+8
django amazon-s3 amazon-web-services amazon-ec2
source share
4 answers

I worked with systems using Fabric to deploy to multiple servers

+6
source share

I am a former lead developer at The Texas Tribune , which is 100% Django. We turned to EC2 using RightScale . I personally did not write deployment scenarios, but this allowed us to quickly and quickly introduce new instances into rotation and scale on demand. it's not cheap, but worth every penny in my opinion.

+2
source share

I agree with John and I will say that Fabric is a tool that is convenient to do. You probably do not want to configure git for automatic deployment using post commit commit, but you may need to configure the command line to run a local test suite, and then click on create if it passes.

Many people run separate dev configuration files and production parameters, rather than setting up the logic there to determine if it is in production. You can inherit from a unified file and then override bits that differ between dev and production. Then you start the server using the production file, instead of relying on a single settings.py parameter.

If you use apache to host the application, you can use a lighter weighting solution. Using fastcgi with nginx would completely eliminate the overhead of Apache. There is also a wsgi module for nginx there, but I don't know if it is ready for this stage.

+1
source share

There is another good way to handle this. For ubuntu / debian amis, it's good to version control and deploy by packing your application in .deb

+1
source share

All Articles