Apache Configuration: Solving “MaxClients Exceeds ServerLimit” Error During Graceful Restart


4 views

When tuning Apache for high-traffic scenarios, many admins encounter a frustrating limitation where ServerLimit changes don't properly apply during graceful restarts. The core issue manifests when trying to increase MaxClients beyond the default 256 threshold.

Apache has specific constraints around modifying ServerLimit:

# This gets ignored during graceful restart
ServerLimit 565
MaxClients 565

The error log typically shows two key warnings:

WARNING: MaxClients of 565 exceeds ServerLimit value of 256 servers
[WARN] WARNING: Attempt to change ServerLimit ignored during restart

The limitation exists because ServerLimit directly affects the shared memory allocation for Apache's process table. This memory structure gets initialized at startup and can't be safely resized during operation. Graceful restarts maintain existing processes while spawning new ones.

To properly apply new ServerLimit values:

  1. Completely stop Apache
  2. Edit httpd.conf with new values
  3. Start fresh

Example configuration that will work:

StartServers        5
MinSpareServers     15  
MaxSpareServers     30
ServerLimit         565
MaxClients          565
MaxRequestsPerChild 2000

After making changes:

apachectl -t -D DUMP_RUN_CFG | grep -E 'ServerLimit|MaxClients'

Should show both values matching your configuration. If they don't, you likely need a full restart.

When increasing these values:

  • Calculate required RAM: (MaxClients * Average Process Size)
  • Monitor swap usage to avoid thrashing
  • Consider using mod_event for better scalability

For environments requiring frequent adjustments:

# Prefork MPM example with auto-scaling

    StartServers        5
    MinSpareServers     5  
    MaxSpareServers     10
    ServerLimit         1024
    MaxClients          768
    MaxRequestsPerChild 10000


When dealing with high-traffic Apache servers, administrators often need to adjust both ServerLimit and MaxClients parameters. The key relationship to remember:

# Correct relationship:
ServerLimit ≥ MaxClients

The warning persists because Apache imposes special restrictions during graceful restarts:

  • ServerLimit cannot be increased beyond its previous value during restart
  • Changes only take full effect after a full stop/start cycle

Here's the complete working configuration example:

<IfModule prefork.c>
    StartServers        10
    MinSpareServers     15
    MaxSpareServers     30 
    ServerLimit         600
    MaxClients          565
    MaxRequestsPerChild 2000
</IfModule>

After making changes, verify with:

# Syntax check
apachectl configtest

# Full restart sequence
service apache2 stop
service apache2 start

# Verify effective values
apachectl -V | grep -i "serverlimit\|maxclients"

When setting these values:

# Calculate based on available memory:
MaxClients = (Total RAM - (OS + other services)) / Average Apache process size

# Example calculation:
# 8GB RAM system with 500MB for OS:
# (8192MB - 500MB) / 20MB ≈ 385

If issues persist:

  1. Check for multiple conflicting configuration files
  2. Verify module loading order (prefork must be active)
  3. Examine systemd/init differences in service management