What is the purpose of the parallel operation of NGINX and Gunicorn?

Many Django application deployments over Amazon EC2 use the NGINX and Gunicorn HTTP servers.

I was wondering what they actually do and why both are used in parallel. What is the purpose of launching them in parallel?

+52
django nginx gunicorn
Nov 01 '12 at 18:00
source share
2 answers

They are not used in parallel. NGINX is a reverse proxy server . He is the first in line. He accepts incoming connections and decides where they should go next. It also (usually) serves static media such as CSS, JS, and images. It can also perform other functions, such as SSL encryption, caching, etc.

Gunicorn is the next level and is an application server. NGINX sees that the incoming connection is for www.domain.com and knows (via configuration files) that it must transfer this connection to Gunicorn. Gunicorn is a WSGI server that basically consists of:

simple and universal interface between web servers and web applications or frameworks

Gunicorn's task is to manage and run a Django instance (similar to using django-admin runserver during development)

Unlike this setting, Apache is used with the mod_wsgi module. In this situation, the application server is actually part of Apache, working as a module.

+71
Nov 01 '12 at 18:18
source share

Nginx and Gunicorn are not used in parallel.

  • Gunicorn is an implementation of the Web Gateway Interface Server (WSGI), which is commonly used to run Python web applications.
  • NGINX is a free, high-performance, open-source HTTP server and reverse proxy server, as well as an IMAP / POP3 proxy server.
  • Nginx is responsible for serving static content, compressing gzip, ssl, proxy_buffers, and other HTTP things. While gunicorn is a Python HTTP server that interacts with both nginx and your real python web application code to serve dynamic content.

The following diagrams show how nginx and Gunicorn interact.

Nginx and gunicorn Overall idea of ​​nginx and Gunicorn

0
May 11 '19 at 18:36
source share



All Articles