Does Django use processes or threads to handle user requests in view?

后端 未结 1 1054
旧巷少年郎
旧巷少年郎 2021-02-04 09:29

Does Django use processes or threads to handle user requests in view?

If Django uses threads I can\'t to use all CPU cores(python global interpreter loc

相关标签:
1条回答
  • 2021-02-04 09:52

    Django is run as a WSGI application. How that happens is determined by your WSGI server (e.g. uWSGI, Gunicorn, mod_wsgi).

    Django's request handler is thread-safe. You can configure your WSGI server to use any number of processes (sometimes called workers) and threads per process.

    As you've mentioned, processes use more memory, but threads are affected by the GIL. A good configuration should find a balance between the number of processes and the number of threads per process.

    0 讨论(0)
提交回复
热议问题