The Apache web server is the most popular web server in the world. This is in part due to its modular design. Apache 2 introduced Multi-Processing Modules, or MPMs. The MPMs change the basic functionality of the web server. They do this by modifying how Apache listens to the network, accepts, and handles requests. A lot of this functionality is rather technical and outside of the purview of this article. This article will briefly explain what the various MPMs are and how they work. For more detailed information on the various MPMs, please visit the Apache Documentation.
All versions of Apache 2.0 and greater run some form of MPM, and there are a variety of MPMs for the various operating systems. This article will only be focusing on those available for the Linux operating system. First you’ll want to determine what version of Apache and which MPM your server currently is running. You can determine this by running the following command on the command line.
httpd -V | grep -i 'version\|mpm'
Running that command will give you output that will look like this:
[root@host]# httpd -V | grep -i 'version\|mpm'
Server version: Apache/2.4.16 (Unix)
Server MPM: event
In this case, the server is running Apache 2.4 and using the Event MPM. This output may be different depending on the Apache version and MPM your server currently is running.
Changing your MPM on a cPanel server is easy. Just run the EasyApache script and select the MPM you want from those available. The list that is present will be different depending on whether you are running Apache 2.0, Apache 2.2, or Apache 2.4. On Apache versions below 2.4, only Prefork and Worker are considered stable. The Event MPM is considered experimental on Apache 2.2 and should only be used with Apache 2.4 or later.
If you are uncomfortable running the EasyApache yourself, please contact Heroic Support® and we will be more than happy to assist you.
With the Prefork module installed, Apache is a non-threaded, pre-forking web server. That means that each Apache child process contains a single thread and handles one request at a time. Because of that, it consumes more resources than the threaded MPMs: Worker and Event.
Prefork is the default MPM, so if no MPM is selected in EasyApache, Prefork will be selected. It still is the best choice if Apache has to use non-thread safe libraries such as mod_php (DSO), and is ideal if isolation of processes is important.
The Worker MPM turns Apache into a multi-process, multi-threaded web server. Unlike Prefork, each child process under Worker can have multiple threads. As such, Worker can handle more requests with fewer resources than Prefork. Worker generally is recommended for high-traffic servers running Apache versions prior to 2.4. However, Worker is incompatible with non-thread safe libraries. If you need to run something that isn’t thread safe, you will need to stick with Prefork.
Each process under Event also can contain multiple threads but, unlike Worker, each is capable of more than one task. Apache has the lowest resource requirements when used with the Event MPM.
Event, though, is supported only on servers running Apache 2.4. Under Apache 2.2, Event is considered experimental and is incompatible with some modules on older versions of Apache. Nevertheless, on high-traffic Apache 2.2 servers where Apache has experienced issues with memory, upgrading Apache to take advantage of the Event MPM can yield significant results.
The Other MPMs
There are a number of other experimental MPMs such as Threadpool, Perchild, and Leader. Liquid Web recommends against running these MPMs. Since they are experimental, there are no guarantees that they will work as expected and we can neither support them nor guarantee that we will be able to fix them.
The addition of the Multi Process Modules to Apache have increased its power and flexibility. The MPMs allow users to change the core behavior. This increases what a user can do with Apache without having to install additional software. If you have any questions regarding this or anything else, please give Heroic Support® a call.