gpt4 book ai didi

python - uwsgi 线程有什么用?

转载 作者:太空狗 更新时间:2023-10-29 21:45:49 26 4
gpt4 key购买 nike

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

关于python - uwsgi 线程有什么用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34182465/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com