Share Increasing Apache ServerLimit on Ubuntu
February 17th, 2009 by ErikI’ve been doing a fair amount of server tuning over the last few weeks and one of the issues I hit this morning was a ServerLimit directive 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 increase the ServerLimit to 384 and the MaxClients to 384.
<IfModule mpm_prefork_module>
StartServers 50
MinSpareServers 20
MaxSpareServers 70
MaxClients 384
ServerLimit 384
MaxRequestsPerChild 0
</IfModule> |
When I would restart the server I would get the following message.
root@app:~# apache2ctl restart WARNING: MaxClients of 384 exceeds ServerLimit value of 256 servers, lowering MaxClients to 256. To increase, please see the ServerLimit directive. |
Apache was running – but still capping out at 256 servers. Erik L. explains that to fully stop the server you need to run “apache2ctl graceful-stop”, wait for requests to complete and then run “apache2ctl start”. If you’re running mod_status.so (status module) you’ll be able to see the correct number of threads available to the server.
root@app:~# apache2ctl status Apache Server Status for localhost Server Version: Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.5 with Suhosin-Patch Server Built: Jun 25 2008 13:54:43 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Current Time: Tuesday, 17-Feb-2009 01:23:16 PST Restart Time: Tuesday, 17-Feb-2009 01:21:45 PST Parent Server Generation: 0 Server uptime: 1 minute 30 seconds 280 requests currently being processed, 64 idle workers W__K_K_C_KWW_KWKWW__W_K_KKW_WK__KK_WKKKWWKKWK_KK_K_K_WKWWW_KKKKK W_WWKK__KK_WK_K_W_W_WWWKW_WKKK___KWKKK_KWW_W_WK_KW__KK_K_K_K__W_ K__KWKKW_WKCKW_KWKWWKCW____WKK__KKKWKKWW__KKK_KK__KWWWKWWW_WWWWW WKW__KWWWWW__KWWW_WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW KKWWWWWWWWWWWWKWWWWWWWWW........................................ Scoreboard Key: "_" Waiting for Connection, "S" Starting up, "R" Reading Request, "W" Sending Reply, "K" Keepalive (read), "D" DNS Lookup, "C" Closing connection, "L" Logging, "G" Gracefully finishing, "I" Idle cleanup of worker, "." Open slot with no current process |
You’ll still get the error message, but as Grig Gheorghiu says, “know when to ignore warnings“. If anyone knows how to get rid of this error, please let me know.
You should follow me on Twitter.
Tags: apache, config, MaxClients, optimization, ServerLimit
February 26th, 2009 at 1:16 pm
I just hit this too- thanks for your useful post. You can fix the warning by declaring the ServerLimit on the line before MaxClients instead of the line after.
Cheers, A.D.
June 4th, 2009 at 7:45 am
If you add ServerLimit above Maxclients it will work
StartServers 50
MinSpareServers 20
MaxSpareServers 70
ServerLimit 384
MaxClients 384
MaxRequestsPerChild 0
August 30th, 2009 at 10:43 am
hey, how much RAM do you have on the server for such settings? Thanks a ton
August 31st, 2009 at 7:57 am
@gonzague – The machine had 8Gb
October 26th, 2009 at 8:18 am
I thought I had the same problem, ServerLimit won’t increase after restart, even though I have ServerLimit line above the MaxClients line. It turns out that to change ServerLimit you have to completely shutdown Apache and start again.