1

Does the Apache mod_status output give any insight to tuning Apache prefork config?

For example, using Apache's mod_status, I figured out that

  • My server gets 3 requests/sec average, the range is 2-10 requests/sec, and one spike was 28 requests/sec.
  • My server has 7 average requests currently being processed, the range is 1-86.
  • My server has 10 average idle workers, the range is 0-99.

Does this give any insight as to what my Apache prefork settings should be - in particular, MinSpareServers, MaxSpareServers, MaxClients, and MaxRequestsPerChild? Or is this data unrelated?

1
  • I hope you were able to get your issue resolved. If my answer was helpful to you, I'd appreciate if you could mark it as accepted and/or upvote it so I can get credit for it. Thanks
    – sa289
    Jul 13, 2015 at 20:50

1 Answer 1

2

You'd want to make sure your MaxClients is set to something comfortably above the typical peaks (which is sounds like is 10 in your case but you saw a burst up to 86 once, so maybe 150 to allow some breathing room in case you get a bigger burst). This way you won't run out of connections should that happen and users experience slowness. Be sure you have enough RAM on your server to support whatever MaxClients value you set it to (RAM needed under full load = RAM used per Apache process multiplied by MaxClients).

If you don't mind tying up the RAM, you can tell Apache to keep more servers running so they don't need to be forked (created) when more requests come in by increasing MinSpareServers to a number that is equal to your typical peaks (or somewhere close to that). Also if you don't mind tying up the RAM, you can set MaxSpareServers equal to MaxClients and just let Apache decide if it things it's a good idea to keep those extra spares around or not. The side effect of them being kept around will be a performance gain. One note is that even if you don't think you need the RAM, the operating system will put unused RAM to use to boost performance by doing things like caching, so that's one thing to consider when tying up RAM.

MaxRequestsPerChild is not so much of a performance thing but rather to help prevent against things like accidental memory leaks (see http://httpd.apache.org/docs/2.2/mod/mpm_common.html#maxrequestsperchild).

2
  • Thanks for that info. Through another post I was able to calculate that my MaxClients should be 60. MySQL uses around 3GB of my 8GB ram, and each Apache process uses ~50MB. So from what I read, the calculation I did was MaxClients = (8GB - 3GB)/50MB = 3000MB/50MB = 60. I haven't reached the MaxClients limit yet but I'm eager to watch performance during high load. Apr 16, 2015 at 13:27
  • Np. If this answer addressed your question, don't forget to mark the answer as accepted.
    – sa289
    Apr 21, 2015 at 20:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.