uwsgi的推荐设置 [英] Recommended settings for uwsgi
问题描述
我有一个mysql + django + uwsgi + nginx应用程序,最近我在uwsgi的默认配置上遇到了一些问题,因此我想重新配置它,但是我不知道建议的值是什么.
I have a mysql + django + uwsgi + nginx application and I recently had some issues with uwsgi's default configuration so I want to reconfigure it but I have no idea what the recommended values are.
另一个问题是我找不到uwsgi使用的默认设置,这使调试工作非常困难.
Another problem is that I couldn't find the default settings that uwsgi uses and that makes debugging really hard.
使用默认配置,该站点在实际流量下太慢(等待uwsgi套接字等待的请求太多).因此,我使用了一些教程中的配置,它的cpu-affinity=1
和processes=4
可以解决此问题.配置中也有limit-as=512
,现在应用程序出现MemoryErrors,所以我认为512MB还不够.
Using the default configuration, the site was too slow under real traffic (too many requests stuck waiting for the uwsgi socket). So I used a configuration from some tutorial and it had cpu-affinity=1
and processes=4
which fixed the issue. The configuration also had limit-as=512
and now the app gets MemoryErrors so I guess 512MB is not enough.
我的问题是:
-
如何知道推荐的设置?我不需要它是超级完美的,只是为了以下降的方式处理流量并且不因内存错误等而崩溃.具体来说,
limit-as
的推荐值是我目前最需要的.
How can I tell what the recommended settings are? I don't need it to be super perfect, just to handle the traffic in a descent way and to not crash from memory errors etc. Specifically the recommended value for
limit-as
is what I need most right now.
uwsgi的默认设置是什么?
What are the default values of uwsgi's settings?
谢谢!
推荐答案
我们通常运行非常小的应用程序...每分钟很少有2000个请求.但是无论如何,很难比较不同的应用程序.那就是我们在生产中使用的:
We run usually quite small applications... Rarely more than 2000 requests per minute. But anyway its is hard to compare different applications. Thats what we use on production:
Haharakiri = 20 # respawn processes taking more than 20 seconds
limit-as = 256 # limit the project to 256 MB
max-requests = 5000 # respawn processes after serving 5000 requests
daemonize = /var/log/uwsgi/yourproject.log # background the process & log
uwsgi_conf.yml
uwsgi_conf.yml
processes: 4
threads: 4
# This part might be important too, that way you limit the log file to 200 MB and
# rotate it once
log-maxsize : 200000000
log-backupname : /var/log/uwsgi/yourproject_backup.log
我们使用以下项目来部署和配置django应用程序. (这里没有文档,对不起...仅供内部使用)
We use the following project for deployment and configuration of our django apps. (No documentation here sorry... Just used it internally)
如何确定配置是否正确...?由于这很大程度上取决于您的应用程序,因此我建议使用一些监视工具(例如newrelic.com)并进行分析.
How can you tell if you configured it correctly... ? Since it depends much on your application I would recommend to use some monitoring tools such as newrelic.com and analyse it.
这篇关于uwsgi的推荐设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!