简体   繁体   中英

AWS elastic beanstalk + Nginx + Gunicorn

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 ie 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.

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:

  1. Create a Virtual Environment (using virtualenv ) to keep track of your python dependencies as you develop
  2. Configure your project for Elastic Beanstalk. This includes freezing your virtualenv to a requirements.txt file, and configuring EB Extensions for django's WSGI.
  3. 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.

You definitely still need some reverse proxy on your application level. While ELB has no specific reverse proxy, Application Load Balancer (ALB) would kind of replace need of proper reverse proxy as it allows to define path-based routing. Nevertheless it's not a full substitute of nginx in this case. With nginx you are equipped with tools that which allows you to do almost unlimited things that may be required by your application as it keeps on growing up when the serious traffic comes into play.

What's more, for Django application on production you definitely want to run it with some uwsgi for example as it's capable of handling traffic any "development" server as the one shipped with django could not do.

With all the things described above, you're in position of charge here by having all those nginx and uwsgi stuff ready to go with your application.

I love to have all applications we do on daily basis contenerized with Docker on EBS multi-container environment. There we've got nginx, uwsgi, so we can do anything we need.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM