python – 用于什么uwsgi线程?

我在uwsgi.ini文件中看到有一个配置

[uwsgi]
socket = 127.0.0.1:3031
chdir = /home/foobar/myproject/
wsgi-file = myproject/wsgi.py
processes = 4
threads = 2
stats = 127.0.0.1:9191

我知道每个请求都在不同的过程中提供.然后用于什么线程?

解决方法:

进程和线程都可用于增加并发性.
线程比进程便宜并且使用更少的资源,但由于Python GIL,可能并不总是并行运行.

另外,引用uWSGI documentation

There is no magic rule for setting the number of processes or threads
to use. It is very much application and system dependent. Simple math
like processes = 2 * cpucores will not be enough. You need to
experiment with various setups and be prepared to constantly monitor
your apps. uwsgitop could be a great tool to find the best values.

上一篇:nginx+uWSGI+django+virtualenv+supervisor发布web服务器


下一篇:Python web 协议和服务器基础