Apache gotcha with ServerLimit
A little gotcha that happened to me a while ago; A rather sizeable customer had just launched a new campaign and had problems with HTTP content matching alerts being thrown rather frequently.
This particular solution has got five loadbalanced webservers and two database back-ends designed to cater for a reasonably high amount of traffic and shorter bursts of traffic surges.
The servers did not seem to be under any particular load, and I could connect to localhost just fine (telnet is a magnificent troubleshooting tool, is it not?). I looked at the cacti graphs on all four servers in the cluster, and noticed in the apache scoreboard that there were more or less exactly 256 threads running on all five servers. `ps ax|grep httpd | wc -l`confirmed this. So I went and edited httpd.conf and raised ServerLimit and MaxClients to 750 (from 256).
Then here’s my mistake – being the nice guy that I am – I did /usr/local/apache/bin/apachectl graceful . But got this in error_log:
WARNING: MaxClients of 750 exceeds ServerLimit value of 256 servers,lowering MaxClients to 256. To increase, please see the ServerLimit directive.
Hm, why would maxclients be respected, but not serverlimit? Short answer is; when doing graceful, the parent apache uber-process is not killed and restarted and this value can not be changed without a full blown restart. Pretty obvious once you know about it! I sifted through apachectl, and all it did was:…
case $ARGV instart|stop|restart|graceful|graceful-stop)
$HTTPD -k $ARGV ERROR=$? ;;
…so obviously an `apachectl restart` would not be sufficient either. So long story short, when changing the ServerLimitdirective, a graceful-stop and a start is necessary! At least this is true for this custom compiled apache 2.2.3.
Posted in Webservers
November 12th, 2008 at 1:05 am
Thanks dude!
December 7th, 2008 at 2:37 am
wow nice info.
i’ve been jumpin around just to loook those answer for weeks.
thanks.
February 17th, 2009 at 5:31 pm
[...] that wasn’t being applied to the server upon a restart. Scouring Google I stumbled upon a post by Erik Ljungstrom that helped me fix my problem. You can see in my apache2.conf snippet, I’ve added a line to [...]
August 19th, 2009 at 9:50 pm
That’s actually a documented feature:
[T]his directive sets the maximum configured value for MaxClients for the lifetime of the Apache process. Any attempts to change this directive during a restart will be ignored, but MaxClients can be modified during a restart.
See: http://httpd.apache.org/docs/2.0/mod/mpm_common.html#serverlimit
September 4th, 2009 at 11:45 pm
Hello ,
What i can do with my WHM , it always give me is over the limit (256), using previously saved value (if any) or default (150) , even if i put large number for serverlimit in httpd.conf