Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why would I need a separate webserver for Django?

I noticed that most of the books and tutorials on Django make it very clear that use Django development server as a normal webserver is not OK. But some state that other webservers are optional, that we can use Django server to put the website on the web for everybody to see.

But why exactly? Why do I need (or not) to use Apache, Lighttpd, Nginx, etc. in front of Django - WSGI?

Is Django server not safe in some way? If so, how it is unsafe exactly, and why can't Django just come with a more robust webserver (out of the box, ready to use)?

How exactly those webservers help Django? *I know that those webservers have very useful mods, but AGAIN: couldn't Django just come with a safer "mod-able" webserver?

like image 699
Vitor Avatar asked Sep 02 '16 20:09

Vitor


3 Answers

My understanding is that the folks at Django are not specialized in the server business and they never intended their server code to produce anything other than a way to develop and test on one's local machine without a lot of traffic. Per their own documentation

Now’s a good time to note: don’t use this server in anything resembling a production environment. It’s intended only for use while developing. (We’re in the business of making Web frameworks, not Web servers.)

like image 119
Matt Cremeens Avatar answered Sep 20 '22 10:09

Matt Cremeens


It comes down to the goal of the Django project and the efficiency gains associated with re-use (as opposed to reinventing the wheel).

The stated goal for Django is to offer a web application framework that enables quick development and minimal code. The original tagline was a "web application framework for perfectionists with deadlines".

That goal can be accomplished with a simple single-threaded web server that simply facilitates development and testing.

The goal of Apache httpd, Nginx, IIS, etc. on the other hand is to offer exceptionally scalable and performant web servers. These applications are highly configurable as all applications differ and there's no one size fits all. They also require different expertise to design, implement and maintain.

So it makes a lot of sense that with limited resources (developer time), the Django team chose to focus on the web-app framework, and leave the production-ready web server to another project.

like image 39
Dwight Gunning Avatar answered Sep 23 '22 10:09

Dwight Gunning


It is not something specific to Django, that is the case for all modern web frameworks that I know, they all have this very simple built-in web server that we use only for development purposes, and the reason is obvious, it does not make any sense to reinvent the wheel since we already have very powerful web servers.

Another important thing is that you can use one web server for one or more web applications that might be developed using different programming languages and web frameworks.

like image 36
ettanany Avatar answered Sep 20 '22 10:09

ettanany