Forum Moderators: phranque
coopster recently put me on to performance tuning for apache [httpd.apache.org]
however after playing half-heartedly with the following settings
KeepAlive on
MaxKeepAliveRequests 200
KeepAliveTimeout 5
MinSpareServers 20
MaxSpareServers 40
StartServers 20
MaxClients 128
MaxRequestsPerChild 10000
i really didn't notice much difference to the server.
can anyone help me with
a) a clear explanation of what each of these means (no i don't understand the apache docs ;)
b) some useful benchmarking tips for twiddling with the above to optimise performance?
many thanks in advance!
As far as useful benchmarking tips, the most useful thing to remember that benchmarks are useless. Keep that in the back of your head when benchmarking.
Now that you have that in your head, the exception to the "benchmarks are useless" rule is a test which accurately duplicates a specific production condition for which you are trying to test. To determine what to test for, you need to know what kind of traffic you push, what kind of content you have, and so forth. Is you site mostly static content? Dynamic? High-traffic or low? What's the average filesize being returned? Do you have a database back-end? What are you tuning *for*? You can tune to reduce memory, network traffic, CPU, etc. Just saying "I'm gonna benchmark" means nothing; in order to do it *well* you need to answer lots of questions and understand the answers to them, then set up your test environment.
i phrased my question badly.
i think i know what those terms mean - but that still doesn't help me in understanding what they do to a server and how they relate to visitors numbers and cpu / ram usage. that is why i asked.
these are my best guesses. can you confirm or deny?
1) MaxClients 128 - each apache server generates child processes to cope with http requests. these child processes are the apache lines which i see when i run a top command. the maxclients setting limits the total number child processes which can exist at any one time (regardless of the number of servers in action).
2) MaxRequestsPerChild 10000 - each child process handles lots of requests. a request is each bit of the page which has to be downloaded - each image, css files, etc. in the above setting, there is a limit on these - 10,000 requests before the child is terminated and another is started.
3) KeepAliveTimeout 5 - each child process is kept alive for 5 seconds waiting to see if it will be used again. if not, it is terminated. (is this good, what are the benefits of raising it?)
4) MaxKeepAliveRequests 200 - a maximum of 200 child processes can be kept waiting at any one time.
HOWEVER, i seem to have contradicted myself in points 1) and 4) - i have limited child processes to 128, but have set 200 as the max number of these which can be kept waiting (keepaliverequests). this limit can never be reached according to my settings above - or have i misunderstood?
any clarification would be much appreciated!
p.s. your comments on benchmarking are very useful thanks.
No offense, but if you don't understand what those settings do, then you won't be able to tune Apache properly to your environment. So, step 1: learn what they mean (and no, I'm not going to spoonfeed you; sorry. =) ).
In fairness, the Apache manuals are *very* badly written - as are most computer manuals and books.
On a more constructive note, our own busy server did go through a phase where the CPU load was in excess of 50% and requests became very slow. The CPU load and hence response times were the result of server-side scripts running, and were improved by adding some more RAM to the server.
Despite realising an average of 400 concurrent connections peaking at over 900 and bever dipping below 150 (taken on monitoring a 24 hour period at 1 minute intervals) the default settings seem to work fine, though they shouldn't!
Matt
1) the maxclients setting limits the total number child processes which can exist at any one time (regardless of the number of servers in action).
2) there is a limit on these - 10,000 requests before the child is terminated and another is started.
3) KeepAliveTimeout 5 - each child process is kept alive for 5 seconds waiting to see if it will be used again. if not, it is terminated. (is this good, what are the benefits of raising it?)4) MaxKeepAliveRequests 200 - a maximum of 200 child processes can be kept waiting at any one time.
No. You need a better understanding of what keep-alives are; read [httpd.apache.org ] for starters and run some google searches. Possible search terms:
http keepalives pipelining
If you're feeling brave, you can read section 19.7.1 of RFC 2068, (available at [mirrors.rcn.net ]), which describes HTTP keep-alives. Once you have a better handle on keep-alives, re-read the Apache docs on the KeepAlive and KeepAliveTimeout directives.
Good luck.
...our own busy server did go through a phase where the CPU load was in excess of 50% and requests became very slow. The CPU load and hence response times were the result of server-side scripts running, and were improved by adding some more RAM to the server.