Skip to content

Apache MPM tuning under load on cPanel/WHM

Apache's prefork, worker, and event MPMs each behave differently under load. Most cPanel hosts default to one of them without knowing why — here is how to pick and tune.

Apache on cPanel defaults to a multi-processing module — usually event on modern installs, sometimes still prefork on legacy ones. The defaults assume a small server with light traffic. On a real shared host under load, the wrong MPM choice or the wrong tuning means either dropped connections or hundreds of idle processes wasting RAM. This is one of the cheaper fixes once you know what to look for.

What’s happening

The three MPMs:

  • prefork — one process per request, no threading. Required when running PHP via mod_php. Predictable but memory-heavy: 100 concurrent requests = 100 processes, each holding the full PHP interpreter.
  • worker — multiple threads per process. Lighter on memory, requires thread-safe PHP (so PHP-FPM, not mod_php).
  • event — like worker, plus dedicated threads for managing keep-alive connections. Best choice for high-concurrency cPanel hosts running PHP-FPM.

The relevant knobs: ServerLimit (process cap), MaxRequestWorkers (concurrent request cap), ThreadsPerChild, MinSpareThreads/MaxSpareThreads. The default MaxRequestWorkers of 400 is too low for a busy server and too high for a cheap one — neither extreme is right by default.

How to verify

Which MPM is active:

httpd -V | grep MPM
apachectl -M | grep mpm

Live worker stats from mod_status (must be enabled in WHM > Apache Configuration > Global Configuration):

curl -s http://127.0.0.1/server-status?auto
curl -s http://127.0.0.1/server-status | grep -E 'BusyWorkers|IdleWorkers'

If BusyWorkers is at or near MaxRequestWorkers and IdleWorkers is zero, the server is queueing requests. New visitors see slow responses or 503s. If IdleWorkers is in the hundreds and memory is tight, the spare-thread tuning is too generous.

The fix

  1. Switch to event MPM on any modern cPanel host running PHP-FPM. WHM > Apache Configuration > Global Configuration, MPM section. Rebuild Apache config and restart.
  2. Size MaxRequestWorkers to RAM. Assume each Apache process needs 30-50 MB (without mod_php) plus the PHP-FPM child memory. On a 16 GB host running PHP-FPM, 400 workers is realistic; on 4 GB, 100 is safer.
  3. Tune spare thread bounds. MinSpareThreads=25 MaxSpareThreads=75 ThreadsPerChild=25 ServerLimit=16 gives you a 400-thread cap with breathing room and reasonable startup.
  4. Confirm with mod_status. After tuning, the steady state should show BusyWorkers rarely above 70% of the cap and IdleWorkers always positive but not extravagant.

The deeper question once Apache is tuned: are you using Apache at all when LiteSpeed is available on cPanel? On a LiteSpeed-licensed host, the MPM question is moot. For Apache-only setups, this tuning matters. Stack Harbor sets MPM and PHP-FPM together as part of cPanel server administration.