I'm running 3 separate virtualhosts for my website (Django w/ wsgi for the main site, another Django w/ wsgi for the mobile version of the site, and a 3rd for Wordpress serving as the site's blog). After a few weeks, the swap memory climbs up to the point where my load & ping times become really slow. When I look at top
, I see that there are several Apache processes each taking up a significant amount of memory, and have been running for at least an hour.
This is on an Ubuntu 10.04 server running on Rackspace cloud (medium instance).
I'm running the two django sites with wsgi in daemon mode (threads = 1, processes = 2).
My apache2.conf main settings look like this (with several "irrelevant" things stripped out to minimize the size of this post -- if you're expecting another setting, let me know, and I can check if I have it in there):
Timeout 120
KeepAlive Off
MaxKeepAliveRequests 100
KeepAliveTimeout 15
<IfModule mpm_prefork_module>
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxClients 150
MaxRequestsPerChild 0
</IfModule>
<IfModule mpm_worker_module>
StartServers 2
MinSpareThreads 25
MaxSpareThreads 75
ThreadLimit 64
ThreadsPerChild 25
MaxClients 150
MaxRequestsPerChild 0
</IfModule>
<IfModule mpm_event_module>
StartServers 2
MaxClients 150
MinSpareThreads 25
MaxSpareThreads 75
ThreadLimit 64
ThreadsPerChild 25
MaxRequestsPerChild 0
</IfModule>
One thing I've seen suggested is to switch away from Apache to a "less bloated" web server. I'm open to this idea, but am guessing that I would be best moving Wordpress off the server so that I don't need PHP (or do these other web servers offer php and python solutions together?)
Let me know if you want any more information. Thanks!
Use the display-name option as documented in mod_wsgi documentation to label the mod_wsgi daemon processes. That way you can see with 'ps' if the large processes are in fact the mod_wsgi daemon processes.
http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIDaemonProcess
If they are quite fat, then Apache or mod_wsgi isn't anything to do with it. It is going to be because your applications are themselves fat. This may be because of excessive caching of data in memory or resource leakage.
If the labelled mod_wsgi daemon mode processes aren't fat, then you may have not delegated the Python applications to run in the daemon processes properly. That or your PHP application is the problem.
http://code.google.com/p/modwsgi/wiki/CheckingYourInstallation#Embedded_Or_Daemon_Mode
In short, when your application is fat, it isn't going to matter what hosting mechanism you use, they will still be fat and Apache and mod_wsgi have got nothing to do with it unless you have stuffed up the Apache configuration.