Wilmott-IT Services - Central Coast based Business IT Systems Management.
AusWebHost - Australia Based Web Hosting Provider. Offering Web Hosting, Dedicated Servers and other Hosted Services including Hosted Email
myTravelBlog - Create your own travel blog for free today! Link to Facebook to automatically update your status and photos everytime you submit a story!

Monday, January 31, 2011

Reducing Memory Footprint of Apache Services « Unwinding the Stack

Interesting article outlining how to reduce Apache's Web Server, httpd's memory/cpu footprint. Very handy when running Apache in Hosting company
Reducing Memory Footprint of Apache Services « Unwinding the Stack

And also this serverfault.com thread

Thanks everyone for your answers! Following your suggestions I've been able to reduce my memory usage to 195M SWAP and 108M RSS, without touching my code (I'll definitely optimize it soon, but this was supposed to be a solution to get me out of trouble fast).
Here's the list of things I did:
Got rid of the wildcard used in VirtualHost entries. Instead of *:80 and *:443, I used the real IP of my server.
Changed Apache's prefork MPM. These are the values I ended up using:
StartServers           1 MinSpareServers        1  MaxSpareServers        5  ServerLimit           16 MaxClients            16 MaxRequestsPerChild    0 ListenBacklog        100 

These are by no means magical numbers. I've spent some time trying different values and combination, and then testing them against the real usage of my server and everyone should do the same in their enviroment. For the record, my server receives close to 2M pvs/month, serving both dynamic pages and assets at a regular rate - no digg effect. The intention, again, was to reduce the memory footprint, not to improve performance or HA.
Reference:
Tunned down Apache's KeepAlive. By setting KeepAliveTimeout to a lower value (2 in my case) I can expect less server processes just waiting on connections with idle clients that may not request any more content.
Removed MySQL's unused module. I added skip-innodb to MySQL's my.cnf. Massive memory consumption reduction.

There are also some remarkable good suggestions that I couldn't personally do:
  • Remove PHP modules you do not need. The PHP on my server has most mods already compiled, I'll probably try my own minimal PHP on other VPS.
  • Switch to nginx with php-fastcgi. That's another good advice that I'll be trying soon, but right now I can't risk the downtime.

After following these instructions I was able to reduce my own hosting requirements significantly and encourage everyone to give these tips a go.


1 comment:

Anonymous said...

http://serverfault.com/questions/21106/how-to-reduce-memory-usage-on-a-unix-webserver

Engadget

Hack a Day

Slashdot

IntoMobile » Android

Techmeme

Koen's blog

Interesting Blogs