Apache · Configuration and operations

How do you tune Apache MPM directives safely?

Hardmpmtuningcapacity planningUpdated Oct 2026
Quiz this track

Short answer

Start from the MPM's memory model, set ServerLimit and ThreadsPerChild so their product matches MaxRequestWorkers, and size that product against available memory and backend capacity rather than a copied template.

For event and worker, MaxRequestWorkers is bounded by ServerLimit multiplied by ThreadsPerChild. Setting MaxRequestWorkers higher than that product has no effect, and setting ServerLimit too high reserves capacity you may never use. StartServers, MinSpareThreads and MaxSpareThreads control how quickly the pool adapts.

apache
<IfModule mpm_event_module>
  ServerLimit              16
  StartServers              4
  MinSpareThreads          50
  MaxSpareThreads         200
  ThreadsPerChild          25
  MaxRequestWorkers       400
  MaxConnectionsPerChild    0
</IfModule>
16 processes times 25 threads equals a 400-worker ceiling.

How to reason about the numbers

  • Measure resident memory per child process under realistic load
  • Reserve memory for the OS, page cache, PHP-FPM, databases and monitoring agents
  • Keep some worker headroom for bursts, but not so much that the backend is overwhelmed
  • MaxConnectionsPerChild above zero recycles workers to limit leaks, at the cost of churn
  • Check ulimit -n; each connection consumes a file descriptor
  • Watch the scoreboard for threads in reading, writing, keep-alive and closing states

Prefork uses a different model: ServerLimit and MaxRequestWorkers are process counts, StartServers and MinSpareServers control the pool, and memory per process is much higher. Do not copy event tuning into prefork or vice versa; the directives overlap but mean different things.

After changing MPM settings, reload and observe for at least a full traffic cycle. A configuration that looks fine at noon can exhaust memory during a nightly batch or a traffic spike.

Follow-ups you should expect

Interviewers use these to check whether the first answer was understanding or memorisation.

  1. 1How is MaxRequestWorkers derived for event MPM?
  2. 2What does MaxConnectionsPerChild trade off?
  3. 3How do you estimate memory per worker?
  4. 4Why does prefork tuning differ from event tuning?

Say it in the interview

For event and worker I set ServerLimit times ThreadsPerChild to the worker ceiling I actually want, then size that against memory and backend capacity. I measure resident memory per child instead of guessing. I watch the scoreboard and file descriptor limits, and I leave headroom for bursts. I would not copy an event config onto prefork because the directives mean different things.

Use this as a model, not a script. Saying it in your own words is what makes it survive follow-up pressure.

Related questions

Reading is step one

Now say it out loud.

Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live Apache mock interview and get scored feedback on depth, clarity and confidence.