简体   繁体   中英

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). I also host some PHP sites on these servers.

Current wsgi config looks like this:

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.

Here is a quick snippet of documentation about this maximum-requests option...

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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