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?

runningonplants
  • 287
  • 2
  • 10
  • 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 '15 at 20:50

1 Answers1

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).

sa289
  • 1,308
  • 2
  • 17
  • 42
  • 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. – runningonplants Apr 16 '15 at 13:27
  • Np. If this answer addressed your question, don't forget to mark the answer as accepted. – sa289 Apr 21 '15 at 20:14