In my error logs I see:

server reached MaxClients setting, consider raising the MaxClients setting

My MaxClients setting is 150. However when I calculate what seems to be an optimal MaxClients setting I come up with:

Mem used by 1 Apache process = 16
Mem available to Apache = 197

MaxClients = 12 (197/16)

So should I knock MaxClients way down to 12 because my calculations show that is all the RAM I have available or should I raise the limit as the error log suggests (or are my calculations worthless because I'm misunderstanding something)?


Consider setting KeepAlive Off in your httpd.conf if you are running a prefork Apache. Rather than each child holding an inactive connection open Apache will close each connection after fulfilling it. This will reduce the overall connections and child processes needed to serve. It does add a bit of extra time because each new request does have to renegotiate with your server rather than reusing an open connection.

(edit) Oh yeah the question. I'd leave MaxClients alone or set it based on the RAM you have. Assuming you have more than enough RAM, rule of thumb is 2-4x the number of CPU cores you have assuming your backend isn't very slow, else use RAM as the limiting factor. However I think turning off KeepAlive is going to drop the number of children you need to something fairly normal and you'll stop hitting the limit.

(edit2) Now here's where it gets tricky. If your Apache server is an application server which primarily runs PHP, Ruby, etc code and process data it gets from various backends or disk into rendered pages the 2-4x rule works. Generally you're going to be burning 250ms of CPU per page view if it's heavy uncached page so or 4 page views per core. If you have a standalone server you'll be able to serve more requests because lots of them will be small images, css, js, etc which would normally be served off another set of servers for an application server. I assume you have one server so leaving the whole thing alone is probably in your best bet.

At my last job we ran 8core/8GB frontend machines with 50 MaxClients and KeepAlive Off which worked pretty well. In some cases setting MaxClients to 100 got slightly better benchmarks, but overall latency of page generation went up because most of the time we were blocking on various backends or starting to starve for CPU.

  • 1
    Not really what the question wanted but still it'll help with the issue +1 – Jacob Feb 14 '11 at 0:33
  • I have 4 cores so that would put my MaxClients at 8-16... but you say to leave MaxClients alone? Going from 150 to 16 seems pretty drastic. Are you saying it doesn't really matter? Is that why you say leave it alone? – Lothar_Grimpsenbacher Feb 14 '11 at 0:53
  • To answer your question simply, yes I'd let it alone because it probably won't matter if KeepAlive On is truly your problem. – kashani Feb 14 '11 at 1:21

Instead of running that calculation I would experiment to see what your server is really capable of handling. That calculation is more or less a guide line but to be certain about your server you just have to stress it to find out if that is possible.

  • You should consider providing instruction or links explaining how to stress test apache. Saying "you just have to stress it" is about as useful as saying "read the man page" – iainlbc Feb 14 '11 at 19:51
  • I should have I wasn't paying attention, I'll edit it – Jacob Feb 14 '11 at 19:55

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.