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
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With