I have a VPS running apache that keeps running out of memory at Dreamhost. Dreamhost says that the problem is the wordpress configuration, but I think that's their stock answer. I've looked and the main web hosting is coming from mediawiki. I sometimes have 20-30 http processes running, and they are all running php, and mediawiki is powering my top two sites.
So I am looking for suggestions on ways to reduce the memory footprint of mediawiki. I'm currently running version 1.16.4, which I see is significantly behind the current version. (Dreamhost is supposed to upgrade it for me, but apparently they haven't.)
- Does version 17.2 have lower footprint than 16.2?
- Is there a clever way that I could use caching to reduce the amount of memory?
- Are there configuration options that will reduce the memory?
- Why do I have both apache httpd running and php5.cgi running?
- Is there an easy way to find out which mediawiki parts are using the most ram?
- Is there a way to reduce the number of files that are fetched? My web logs are filled with fetches to user.gif, bullet.gif, external.png, document.png --- how come mediawiki's themes don't use sprites?
Thanks!
My first suggestion would be to ensure you are fixing the right problem.
Determine what process(es) are actually using your memory.
Reduce Apache's memory usage
There are additional suggestions on this very good guide to optimizing Apache for low memory.
Does version 17.2 have lower footprint than 16.2?
Is there a clever way that I could use caching to reduce the amount of memory?
There are some less than ideal options you may consider:
Why do I have both apache httpd running and php5.cgi running?
Is there an easy way to find out which mediawiki parts are using the most ram?
Is there a way to reduce the number of files that are fetched? My web logs are filled with fetches to user.gif, bullet.gif, external.png, document.png --- how come mediawiki's themes don't use sprites?
If possible, switch from Apache to lighttpd or nginx. Those can serve your static content very effectively. Then configure something like FastCGI or fcgid for your dynamic content. That way you can effectively separate the static and dynamic content and isolate those from each other.
And yes, I purposely left out the web links for each keyword I used; Google them and decide what fits your needs.
I would suggest you to migrating away from the CGI/FastCGI in favour of PHP-FPM + nginx. PHP-FPM keeps a pool of PHP interpreters spawned and doesn't spawn every single interpreter per request (which I think even FastCGI does).
From my own tests I've seen memory consumption drop by min 15% up to 35% in combination with a well configured bytecode optimizer (I use APC with good results). The real deal was getting away from Apache and FastCGI as the apache workers pool was spawning too many childs and each of them in turn was spawning PHP interpreters, which just after 4/5 days lead to out of memory / swapping with poor performance.
As suggested above analyze what is eating your memory right now, I bet APC is causing that as per this post
I can confirm the high memory use of MediaWiki - but only as far as compiled PHP bytecode is concerned. The APC cache viewer reveals that the compiled bytecode amounts to roughly 20 MB after just a few hits. The bytecode for all "normal" sites (not using WordPress, Drupal or Joomla) are less than 1 MB.
Then the real memory use reported by PHP: A quick test revealed that a MediaWiki page load only consumes about 5 MB of memory which is pretty much the same as that of Joomla. Some more lighweight content management systems use considerably less: some 1.8-3 MB per page load (of course depending on the complexity of the page structure).
As for bad memory use I have seen, though, that a standard WordPress installation and an utterly simple page may use up to 20-30 MB memory, with more complex page structures much more and quite a bit of CPU time. So DreamHost really knows the most common problem.