Home » Linux » Learn More » Apache MPMs Explanation

Apache MPMs Explanation

MPM or multiprocessing modules are part of the apache code that handle incoming requests. So different mpms handle requests differently. It is important to note that although these are called modules they are not like loadable modules. Rather a mpm is seated right inside the apache binary. So at a time you can have only 1 mpm installed, and you must have atleast 1 mpm installed. So, here is the apache mpms explanation.

Check the apache documentation on mpms to learn more.

1. mpm Prefork

This is the oldest and the most basic form of mpm that comes with apache and is compatible with any kind of php server api. It implementes a non-threaded, forking based server that spawns new processes and keeps them alive to serve requests. So there is 1 process per request. Apache keeps processes ready before hand so that incoming client requests dont have to wait for the process to be forked and created. Also the same process is reused further.

The documentation explains its working as follows

A single control process is responsible for launching child processes which listen for connections and serve them when they arrive. Apache always tries to maintain several spare or idle server processes, which stand ready to serve incoming requests. In this way, clients do not need to wait for a new child processes to be forked before their requests can be served.

Due to the process spawning nature of prefork, it is also the slowest one and consumes the most resources. However, because its thread-safe, it is the only mpm that can be used with mod_php sapi. We shall talk more about this later.

2. mpm Worker

Next comes the worker mpm. It solves the limitations of its predecessor prefork. It creates multiple processes like prefork, but also creates multiple threads inside each process. Each of this thread can handle a request. Now since threads share the same resources, this mpm is resource friendly. Infact this is the recommended mpm in all cases, except when you are forced to use mod_php.

The documentation describes its working as

A single control process (the parent) is responsible for launching child processes. Each child process creates a fixed number of server threads as specified in the ThreadsPerChild directive, as well as a listener thread which listens for connections and passes them to a server thread for processing when they arrive.

Mpm worker can be used with any php sapi like cgi, suphp, fastcgi, fpm (except modphp).

There are many php extensions that are not thread safe, therefore if you attempt to run mpm worker with mod_php then the apache server crash from time to time. On ubuntu for example installing modphp would automatically remove mpm worker.

3. Mpm Itk

This is another mpm that is similar to prefork, but has the ability to run separate vhosts (sites) with a separate uid/username. It is non threaded.

It is described as

The ITK Multi-Processing Module (MPM) works in about the same way as the classical “prefork” module (that is, without threads), except that it allows you to constrain each individual vhost to a particular system user. This allows you to run several different web sites on a single server without worrying that they will be able to read each others’ files.

This is a third-party MPM that is not included in the normal Apache httpd.

So this is another mpm that can work with any php sapi including mod_php. But since its not threaded, not recommended. Also it is not an official apache mpm.


Worker is the best performing mpm since it uses threads. But it is incompatible with only modphp.

There are many other mpms like peruser, event, perchild. But there are not used much.

Check Also

Apache Reverse Proxy & Forward Proxy

What is Apache Forward Proxy ? Forward proxies act as a gatekeeper between client browsers …

Leave a Reply

Your email address will not be published. Required fields are marked *