skip to content

How do you determine which multi-processing module a running Apache httpd 2.4 instance is using, and how would you switch it to a different one?

level: juniorimportance: nice to knowfreq 38%

answer

  1. one flag prints it directly
  2. the version banner, not the config file
  3. exactly one may be loaded
  4. enable one, disable the other, restart

basics

~20 s

Run httpd -V (apache2ctl -V on Debian) and read the Server MPM line, or list loaded modules with httpd -M. Switching means loading a different mpm_* module — only one may be active — and doing a full restart.

solid answer

~40 s

The quickest check is `httpd -V`, or `apache2ctl -V` on Debian-family systems, which prints a `Server MPM:` line naming the active MPM. `httpd -M` also works: it lists loaded modules, and exactly one of `mpm_prefork_module`, `mpm_worker_module` or `mpm_event_module` will appear. Since httpd 2.4 the MPM is a loadable module rather than a compile-time choice, so switching is a config edit: on Red Hat-family systems you comment and uncomment the `LoadModule mpm_*_module` lines in the MPM config file under `conf.modules.d`; on Debian-family systems you use `a2dismod mpm_prefork` and `a2enmod mpm_event`, which manage those symlinks for you. Loading two MPMs at once is a startup error. Then restart httpd fully — an MPM change is not something a graceful reload can apply, since it changes how children are created.

code

bash · 5 lines
bash
httpd -V | grep 'Server MPM'
httpd -M | grep mpm
# Debian/Ubuntu equivalents:
apache2ctl -V | grep 'Server MPM'
apache2ctl -M | grep mpm

go deeper

for a junior

Know the one-liner: httpd -V (or apache2ctl -V) prints Server MPM. Being able to answer 'which MPM is this box running' without guessing is the whole expectation here.

for a middle

Explain that the MPM became a loadable module in 2.4, that exactly one may be loaded, and that switching needs a full restart rather than a graceful reload.

for a senior

Point out that the old MPM's tuning numbers do not carry over and that moving to a threaded MPM changes the thread-safety requirement on every module still loaded.

for a principal

Treat the MPM as a platform-wide standard rather than a per-host accident, and make the check part of the build image so an installed module cannot silently pull a fleet back onto prefork.

## Why this is a real question and not trivia Every piece of Apache concurrency tuning is MPM-specific. `ThreadsPerChild` is meaningless under prefork; `MaxRequestWorkers` counts processes under prefork and threads under worker and event; advice you read on the internet is usually written for whichever MPM the author was running. So the first step of any Apache performance conversation is establishing which MPM is actually loaded — and the answer is frequently not the one the team assumes, because installing an in-process language module can silently pull the packaging onto prefork. ## Reading the active MPM ```bash httpd -V | grep 'Server MPM' # Server MPM: event ``` On Debian and Ubuntu the binary is `apache2` and the wrapper is `apache2ctl`, so it is `apache2ctl -V`. The same information appears in `httpd -M`, which lists every loaded module: exactly one line will be `mpm_event_module`, `mpm_worker_module` or `mpm_prefork_module`. `httpd -V` prints more than the MPM — it also shows the compiled-in server root, the config file path and several `-D` defines. Reading the config file path from there is a good habit, because on a host with several installs you may be editing a file the running server never reads. ## What changed in 2.4 In httpd 2.2 the MPM was chosen at build time; you got a binary that *was* a prefork server or *was* a worker server, and distributions shipped several binaries. Since 2.4 the MPM is a dynamically loadable module, so a single binary can run any of them and the choice moved into configuration. This is why the answer to "which MPM" is a runtime question at all. ## Switching The rule is that exactly one MPM module may be loaded; loading two is a fatal startup error, and loading none is as well. Mechanically: - Red Hat family: the `LoadModule mpm_*_module` lines live together in a single MPM config file included from `conf.modules.d`. Comment out the current one, uncomment the one you want. - Debian family: `a2dismod mpm_prefork` then `a2enmod mpm_event`, which toggle symlinks in `mods-enabled`. The tooling refuses to leave you with two enabled. Then restart. A graceful reload lets existing children finish their current work and applies most configuration changes, but changing the MPM changes how children are created and what they contain, so a full stop and start is the honest way to apply it. The same is true of a small number of MPM directives — `ServerLimit` and `ThreadLimit` in particular are only re-read on a full restart. ## Verify after, not just before Two things bite people here. First, each MPM has its own tuning block, and the values that were tuned for the old MPM usually make no sense for the new one — a `MaxRequestWorkers` sized for prefork processes is a very different setting once it counts threads. Second, moving from prefork to a threaded MPM means every loaded module must be thread-safe; if an in-process interpreter module is the reason you were on prefork, switching the MPM without also moving that workload out of the server produces intermittent corruption rather than a clean failure. So confirm with `httpd -V` that the switch took effect, and confirm with `httpd -M` that the module set you are now running threaded is one you are willing to run threaded.

  • Why is a graceful reload not enough after changing the MPM?
    A graceful reload keeps existing children alive to finish their current work and starts new ones from the reread config. Changing the MPM changes what a child fundamentally is — process versus threaded — so you cannot mix old and new children in one server. A full stop and start is required, and the same applies to ServerLimit and ThreadLimit.
  • What happens if two mpm_* modules end up loaded at once?
    httpd refuses to start and logs an error about more than one MPM being loaded. It is a hard failure rather than a precedence rule, which is why Debian's a2enmod/a2dismod pair enforces the exclusivity for you and why the Red Hat MPM config file keeps all three LoadModule lines together with only one uncommented.

saying these in an interview costs you the question

  • Thinks the MPM is still a compile-time choice in httpd 2.4
  • Assumes several MPM modules can be loaded and one wins
  • Expects a graceful reload to apply an MPM change
  • Reads the MPM from the config file without confirming the running server

context