1

I'm entirely uninitiated to the world of web development, and only have a tentative grasp on Django and web development through the test server it works through.

From the guide I'm reading, the author turns to using Nginx once he starts working on site deployment, because Django is "not designed for real-life workloads." What does that mean, and why doesn't it? In terms of justification for using Gunicorn, the author remarks:

Do you know why the Django mascot is a pony? The story is that Django comes with so many things you want: an ORM, all sorts of middleware, the admin site…​ "What else do you want, a pony?" Well, Gunicorn stands for "Green Unicorn", which I guess is what you’d want next if you already had a pony…​

Well and good, but I don't really know what the two are doing for the server. I know for web developers this is like asking what multiplication is to a maths professor, so please excuse the naivety. In your please keep in mind I have almost no knowledge of web development other than what I've thus far learned from this guide, doing my best to understand as much as I can for the previously entirely uninitiated (I'm from a computational programming background).

3

This doc mentions

DO NOT USE THIS SERVER IN A PRODUCTION SETTING. It has not gone through security audits or performance tests.

So I guess that's the part where "Django is not designed for real-life workloads", and we need something reliable and well tested in production.

When a request arrives at your server, it is passed to the web server that could handle multiple requests at once. When the web server determines the request should be processed by your application, the request is then passed to application server. The application server translates the request to some Python objects that can be used by Django web application (through WSGI specification). Then the application server calls the app code in your project with the request Python objects, and gets the response Python objects from your application. The application server then translates the response back to the HTTP response and sends back to the web server. The web server finally returns the response to the caller.

Nginx is one of the web server, and Gunicorn is one of the valid WSGI application server.

enter image description here

Other than dispatching the request and calls the app properly, Nginx handles lots of requests coming in at once and saves CPU/memory resources comparing with the Python code, and Gunicorn runs a pool of worker processes/threads to execute the app code, so they are both considered as improving the performance.

2
  • Why was it possible for me then to have a website up that seemed to working as normal without NGINX? I just had a web server and Django up. – genjong Dec 11 '20 at 18:07
  • Yes you can, you probably just can't handle large traffic with a single server – lennon310 Dec 11 '20 at 18:16
0

I have no experience with Django but I do have experience with Nginx. Nginx is a proxy server that can route http traffic based on rules like path matching. A lot of web applications use nginx as a backend to serve the static content and then route requests to backend services.

Again, I don't have much knowledge about Django but I think you're instructor could have been talking about a development server inside Django that is not suitable for production load and that after you compile the application to static content use nginx to serve that content.

2
  • What is path matching? I hear you that you’re not familiar with Django so I anticipate you may not be able to answer this, but why wouldn’t it be suitable for production load, and what exactly do you mean by production load? – genjong Nov 22 '20 at 4:47
  • What I mean by production load is because Django is "not designed for real-life workloads." real-life workloads. – Sam Orozco Nov 22 '20 at 4:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.