Django: The difference between using a server through manage.py and other servers like gunicorn etc. What's better?

I did initial projects using manage.py and now moved to postgres after sqllite. Many offered guns? What is the difference?

+18
source share
2 answers

The most popular settings are nginx and gunicorn. So, before talking about why gunicorn is recommended instead of runserver, let's quickly find out the difference between nginx - because both claim to be web servers :)

NGINX should be your public access point, it is a server listening on ports 80 (http) and 443 (https). The main reason is handling HTTP requests, that is, using redirects, HTTP authentication if necessary, managing TSL / SSL certificates, and, among other things, determining where your requests ultimately go. For instance. maybe there is a node.js application living on localhost:3000 that is waiting for requests on /foo/api , while gunicorn is waiting on localhost:8000 to serve your awesome application. This function of sending incoming requests to the so-called upstream services (in this case node.js and gunicorn) is called a reverse proxy server.

GUNICORN is a server that translates HTTP requests in python. There are specifications for this called WSGI. For instance. the text parts of the http headers are converted to accessible keys of the key value.

Building Django in a web server does the same. manage.py runserver designed for development (for example, by automatically restarting changes). Gunicorn is focused on production. It has many features in which there is no built-in server. For instance. it can spawn several workflows for parallelizing incoming requests to several processor cores, has the correct logging, is usually optimized for speed, can be configured for very good ratings depending on your settings, and is very actively checked for security problems.

There are other web servers competing with gunicorn, but gunicorn (originally inspired by ruic unicorn) is very popular and easy to set up and therefore not only a very good starting point, but also a very professional solution that is used in very large projects.

+36
source

manage.py runningerver is only a development server; it is not intended for production under any circumstances. You need to use something like Apache, uWSGI, NGINX or some other server to serve your django project after it's ready for deployment.

+7
source

All Articles