Fri, 18 Jul 2008 (1052 EST)
After a day of trying to figure out why one of my web servers was locking up, I found that it was using a bit too much memory. But I had no idea how much, and Linux memory reporting is a bit arcane at best. Especially with something like apache + PHP using shared memory pools. So after some analysis, I came up with the following script:

apachemem.pl

It had the following output:

Total memory available: 3.21G
Total used by apache2 (451 instances): 3.80G
Total used by other processes: 0.12G

Average memory used per apache2 process: 8.63M
Recommended number of processes based on Average: 381
Needed memory for 500 processes based on Average: 4.21G

Max memory used for apache2 process: 17.61M
Recommended number of processes based on Max: 186
Needed memory for 500 processes based on Max: 8.60G

Mean plus two Standard Deviations (bulk of usage under max): 11.28M
Recommended number of processes based on Mean + 2*Stdev: 291
Needed memory for 500 processes based on Mean + 2*Stdev: 5.51G
At the time I ran it, I had 450 instances out of a configured max of 700 active. Come to find out I only had the ram to support about 380 of those at best. :(

Hopefully some other people find this useful, as it's pretty hard to get a straight answer on "How many processes can I support?" Now if only php and the standard modules would officially work with the worker MPM.
All content/ramblings/etc here are copyright (c) 2004 Erik Jacobson (except for the stuff that isn't). Not to be read before swimming, or taken with alchohol. Anything bad is your fault, anything good is mine.