How django handles multiple users

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 works synchronously, will this process slow down if there are more than 2-3 users?

thanks

+6
source share
3 answers

Django is a WSGI application that is a fundamental difference from a server (WSGI) such as Apache. Node.js / Express.js contains its own web server to replace Apache. Django should be hosted by the web server of your choice.

Django is thread safe only. All other aspects of concurrent requests are processed by your web server.

+7
source

Assuming your concern is with a few connections / requests in general, and not users in particular, I should say the following about Django and threads.

Django is definitely thread safe. This is a design consideration that has taken a few people in the past, as the person who follows the development of Django can watch.

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

However, there are concerns about how thread-safe any particular Django-based application is, and it depends on individual developers and third-party developers who use best practices.

Django documentation has separate sections on thread safety. For example, class-based documentation specifically mentions that each class-based view has an independent state. In addition, one of the most common problems is custom template tags, like the address in this section . I am sure there are other links on this subject that I am currently skipping, so I would advise you to keep the documentation if your thread safety issues are too great.

+4
source

Django does nothing to handle this at all. This is completely the job of any server serving Django, be it Apache, gunicorn, uwsgi or something else. These servers are responsible for managing threads or processes to serve multiple requests.

+3
source

Source: https://habr.com/ru/post/988088/


All Articles