Vanilla 1.1.8 is a product of Lussumo. More Information: Documentation, Community Support.
Definitely disable KeepAlive on Apache. But MaxRequestsPerChild should be greater than 1 in my opinion. Forcing Apache to create and destroy a child process for every request is going to make a high-traffic site less responsive. Setting it to 100 or so should be fine on a low-traffic site. With as much traffic you are seeing, you could go higher – 1000 or more – unless your PHP code is leaking tons of memory. More critical are your settings for ServerLimit and MaxClients.
I've been monitoring my slice with KeepAlive Off and MaxRequestsPerChild 1, and I haven't seen an improvement in memory or load avg. If anything, they're a little worse.
Some relevant apache.conf settings:
#KeepAlive On
KeepAlive Off
MaxKeepAliveRequests 100
KeepAliveTimeout 4
<IfModule prefork.c>
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxClients 40
# MaxRequestsPerChild 250
MaxRequestsPerChild 1
</IfModule>
I've never set the ServerLimit directive, but have experimented with many different other prefork directives before nginx calmed the apache2 madness, heh. From apache docs:
With the prefork MPM, use this directive only if you need to set MaxClients higher than 256 (default). Do not set the value of this directive any higher than what you might want to set MaxClients to.
That definitely seemed to be the case. I guess there's a balance to be had here, as when I bump up MaxRequestsPerChild to 1000, I am back to having 8 apache2 processes with 30-50mb each and only around 10mb of free server memory with load avg around .8 -- if I set MaxRequestsPerChild back to 250 I have 200mb of free memory and load avg around .5. The server is not swapping using either one, however.
I don't believe this is from PHP memory leak as apache was steady at ~14mb before I moved over my Django sites and added mod_python. I'll try moving these to nginx-fastcgi.
I'm still seeing queries of 2-3 seconds in my slow log every few minutes, but using EXPLAIN they seem to be optimized with the correct indices (I could definitely be missing something). Is this normal for a site with heavy usage of punbb forums?
If your apache processes are indeed growing to 50MB, you don’t want MaxClients set to 40 on a 1GB slice. If all 40 processes are called into service (during a period of heavy traffic), you’re going to need 2GB RAM just for Apache. Obviously you are going to swap like mad in that scenario.
If you can limit the growth of your apache processes by lowering MaxRequestsPerChild, then you can have a somewhat higher value for MaxClients. But I would not go over 15 MaxClients or so given what you have shown us.
Also, lowering MaxSpareServers to 5 will free up RAM for other purposes when Apache doesn’t need it.
@artagesw: thanks for your help, those changes seemed to have stabilized load around .3 - .6, and recycles the apache processes enough to keep memory open enough for no swapping with fluctuations in traffic. I feel like I've been stabbing in the dark, slowly getting a grasp on these settings, and this helped me understand them quite a bit.
Interesting that when you have Django sites on your slice, you should limit your MaxClients to less than what's normally recommended. But throwing nginx into the mix to alleviate apache from the mundane task of dishing out static files seems to play a big factor in making this possible.
I bet you would see a marked improvement from moving django instances to fcgi+nginx.
Apache will not need to pull in the mod_python framework on each process fork, so the per child memory usage will go down.
As for mysql, you might check to see if you have the query cache enabled. For sites that do lots of simple reads, it can be a big help (with the tradeoff of a little extra memory being used). Of course, do some measurements to see if it is really being beneficial or not.
As for tuning apache, I also recommend disabling keepalives. However, I would keep the maxrequestperchild value higher than 1 (you seemed to have decent results with 250).
If I were in your shoes, I would probably turn on mod_info for a localhost virtualhost, and start collecting some metrics. Take a look at the max and min children over the course of a day, to give youself some ideas of how many spare servers to start with, what the max values you would normally see, etc. I personally use collectd to gather that data, and make my own graphs with rrdtool against the rrds that are output.
Good luck!
:D
Use monin for monitoring so you can figure out what is eating up your resources.
1 to 11 of 11