[Updated to be much more consise!]
I'm new to the world of optimising web servers for lots of traffic, but that's now something I'm getting into.
On Monday our webserver was 'slashdotted' - we got a massive surge of traffic (85,000 visitors in an hour or so) and even though we run Varnish and nginx (which are doing their job properly) the Apache side of things really struggled as there is some dynamic content that gets generated on some requests.
Server currently has 8GB of RAM, it's being upgraded to 32GB very soon, so really I need configuration help for a 32GB system. Currently running 64bit centos.
I've investigated the varnish and nginx setup, they're fine - sensible settings (static content dished out directly by nginx, lots of dynamic stuff dished out by varnish and if it's not in varnish the request is passed through to apache.)
So on to Apache.. we're using the MPM prefork module, each apache process seems to use up a LOT of ram:
S 48 20961 2965 0 75 0 187128 128307 ? ? 00:05:25 httpd S 48 20959 2965 0 75 0 249788 143435 ? ? 00:05:55 httpd S 48 18581 2965 0 75 0 314564 157747 ? ? 00:06:40 httpd
S 0 2965 1 0 78 0 15132 89017 stext ? 00:00:00 httpd S 48 20947 2965 0 75 0 38492 93001 ? ? 00:00:00 httpd S 48 20945 2965 0 75 0 43300 93897 ? ? 00:00:01 httpd
I'm not entirely sure, but I think that one process = one client = one connection to one persons browser. I guess my first question is can someone confirm that? Yes, we're running php and zend framework, MySQL as a database backend on the same server.
Current configuration (server is currently has 8GB ram):
MaxKeepAliveRequests 100 KeepAliveTimeout 2 <IfModule prefork.c> StartServers 8 MinSpareServers 5 MaxSpareServers 20 ServerLimit 200 MaxClients 200 MaxRequestsPerChild 500 </IfModule>
My thinking is currently Apache can theoretically try and use up about 63GB of ram in a worst case scenario with this configuration. Eg 315MB process * 200 maxclients = lots of ram. I'm not entirely sure it works like that, but if someone can confirm that too it'd help!
What I'd like to do is get some advice on what sort of things I should look out for - we want the server to be able to handle another surge of requests at any time and make use of all the new RAM we're getting. I'll get onto optimising MySQL in another question if I can't figure it out myself, but here's the conf just in case that makes a difference: http://pastebin.com/GbJU7AxY
Cheers a lot! John.