Question:
I am working on creating a Django web app using resources on AWS. I am new to deployment and in my production setup (Elastic Beanstalk i.e. ELB based) I would like to move away from the Django development web server and instead use Nginx + Gunicorn. I have been reading about them and also about ELB.
Is Nginx + Gunicorn needed if I deploy my Django app on ELB? As ELB does come with reverse proxy, auto scaling, load balancing etc.
Appreciate the inputs.
Answer:
When deploying Django, one of the recommended deployment methods is using WSGI (see Deploying Django).
This method of deploying Django is also well supported by AWS Elastic Beanstalk, and they even have a Deploying a Django Application to Elastic Beanstalk.
At a high level, you want to do the following:
- Create a Virtual Environment (using
virtualenv
) to keep track of your python dependencies as you develop - Configure your project for Elastic Beanstalk. This includes freezing your virtualenv to a
requirements.txt
file, and configuring EB Extensions for django’s WSGI. - Using the EB CLI to initialize your project, and create an environment.
Behind the scenes, Elastic Beanstalk is going to spin up the Instances, Elastic Load Balancers, etc, as well as configure the instances to accept traffic with Apache, then use the Apache’s mod_wsgi to handle traffic for Django.