简体   繁体   English

使用mod_wsgi + apache运行多个django站点会导致内存问题

[英]Running multiple django sites with mod_wsgi + apache causes memory issues

I'm currently running 50+ Django installations with mod wsgi and noticing that apache isn't dropping memory (so it just keeps holding more and more, and then the sites grind to a halt as the swap disk fills). 我目前正在使用mod wsgi运行50多个Django安装并注意到apache没有丢弃内存(因此它只是保持越来越多,然后当交换磁盘填满时网站会停止运行)。 I also host some PHP sites on these servers. 我还在这些服务器上托管了一些PHP站点。

Current wsgi config looks like this: 目前的wsgi配置如下所示:

WSGIScriptAlias / /var/www/vhosts/glenlivet/tar/src/core/wsgi.py
WSGIDaemonProcess tar.sljol.info python-path=/var/www/vhosts/glenlivet/tar/src:/var/www/vhosts/.virtualenvs/glenlivet/lib/python2.7/site-packages
<Location />
WSGIProcessGroup tar.sljol.info
</Location>

I'm no expert, on this type of configuration, can anyone advise how best to setup each of the vhosts? 我不是专家,在这种类型的配置上,任何人都可以建议如何最好地设置每个虚拟主机?

Thanks 谢谢

There exists a maximum-requests option that could be added to the WSGIDaemonProcess directive which could help clean up the memory apache is holding onto for your Django applications. 存在一个可以添加到WSGIDaemonProcess指令的maximum-requests选项,它可以帮助清理apache为Django应用程序保留的内存。

Here is a quick snippet of documentation about this maximum-requests option... 以下是有关此maximum-requests选项的快速文档片段...

A further option which should be considered is that which dictates the maximum number of requests that a daemon process should be allowed to accept before the daemon process is shutdown and restarted. 应该考虑的另一个选项是,在守护进程关闭和重新启动之前,应该允许守护进程接受的最大请求数。 This should be used where there are problems with increasing memory use due to problems with the application itself or a third party extension module. 这应该用于由于应用程序本身或第三方扩展模块的问题导致内存使用增加的问题。 Documentation 文档

You will incur the overhead of apache having to reload your Django applications but may be more beneficial than swapping due to apache not releasing memory. 您将承担apache必须重新加载Django应用程序的开销,但由于apache不释放内存,可能比交换更有益。

You may have to do some benchmarking to get a feel of what the maximum number of requests should be for your troubling applications but a good starting point could be the code below... 你可能需要做一些基准测试来了解你的麻烦应用程序的最大请求数量,但一个好的起点可能是下面的代码......

WSGIDaemonProcess tar.sljol.info python-path=/var/www/vhosts/glenlivet/tar/src:/var/www/vhosts/.virtualenvs/glenlivet/lib/python2.7/site-packages maximum-requests=10000

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM