我在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
likeprocesses = 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.