Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does django handle multiple users

Tags:

django

web

How does Django handle multiple users? I know that Apache creates a new thread and expressjs uses asynchronous methods. But I do not understand Django because it is working synchronously would'nt this slow down the process if there are more than say 2-3 users ?

Thanks

like image 342
subz Avatar asked May 28 '15 12:05

subz


2 Answers

Assuming that your worry concerns multiple connections/requests in general and not users in particular, I would have to say the following about Django and threads.

Django is certainly thread-safe. It is a design consideration that has occupied several people in the past, as someone that follows Django development can observe.

For that reason, Django can be deployed in a multi-threaded container such as the default threaded mod_wsgi that works with the Apache server, and as such it has been evaluated by many deployments.

There are concerns however on how thread-safe is any particular application that is based on Django, and this is up to the individual developers and maintainers discretion to use best practices.

In Django documentation there are particular sections devoted into the safety of threads. For instance, the class-based views documentation specifically mentions that every class-based view has independent state. Also, one very common concern is custom template tags, as address in this section. I am sure there are other references to the subject too that currently I miss, so I would advise to keep documentation handy if your thread-safety concerns are too big.

like image 109
Wtower Avatar answered Nov 19 '22 07:11

Wtower


Django is a WSGI application, which is a fundamental difference from a (WSGI) server such as Apache. Node.js/Express.js contains its own webserver to replace Apache. Django has to be served by a webserver of your choice.

Django's only job is to be thread-safe. All other aspects of concurrent requests are handled by your webserver.

like image 10
knbk Avatar answered Nov 19 '22 08:11

knbk