Are you worried about your Apache server performance? Okay let’s talk about Apache Multi-Processing Modules (MPMs). There is a documentation for Apache MPM but who has got time to read the documentations. Let’s talk in simple plain english about Apache Multi-Processing Modules (MPMs). All you need is 15 mins to learn Apache MPMs(happy-face).


The MPMs are used to change the basic functionality of the web server. It’s possible due to Apache’s modular design. The MPM, or Multi Processing Module, you use is responsible for just about the entire HTTP session. Starting from listening on the network, taking requests in and most importantly, how to handle those requests. With the MPM you use Apache’s behaviour will change. Apache offers three MPMs to choose from; Prefork, Worker, and Event. You might be wondering which MPM module you should choose. Answer is right below.

How do I select which Apache MPM to use?

Above links explains about the three MPM modules and when to use them. If you don’t know about the Apache MPMs or which one to use , time to start reading.


1. Check what your Apache server has got

Most of the Apache server comes with Prefork module. To make sure whether your server has got Prefork, type the below command and see.

See the output below

If the Prefork Module is installed it should be shown under compiled in modules. prefork.c is shown on the list.

2. Let’s install Apache Worker MPM

Let’s configure Worker MPM. So time to install Worker.

If you are willing to install Prefork or Event MPMs it should be as below

When the installation is completed type apache2ctl -l and see whether the prefork.c/worker.c shows up under “Compiled in modules”.

Note in Ubuntu you can only have one MPM module at a time. It means if you install Worker while the server has got Prefork, Prefork will be automatically removed. When you are switching MPMs it’s a good idea to backup your .conf files.

3. Let’s understand Apache MPM directives

Please read the comments below to understand about the each directives and what they do. Below configurations are extracted from apache2.conf

If you need more information on directives check the documentation.

4. Time to customise the Apache Worker directives as we need


Before customising the directives you need to understand how the directives work. Let me explain in plain English. Server will start 2 child processes which is determined by StartServers directive. Each process will start 20 threads which is determined by ThreadsPerChild directive so this means 2 process can service only 40 concurrent connections/clients(i.e. 20×2=40). So what if more requests come in.

Now if more concurrent users come, then another child process will start, that can serve another 20 users. But how many child processes can be started is controlled by ServerLimit parameter, this means that in the configuration above, I can have 10 child processes in total, with each child process can handle 20 thread, in total handling 10×20=200 concurrent users.

But there is a problem, number defined in MaxClients is 100 here, this means that after 5 child processes, no extra process will start since we have defined an upper cap of MaxClients. This also means that if I set MaxClients to 500, after 10 child processes and 200 connections, no extra process will start and we cannot service more than 200 concurrent clients even if we have increase the MaxClient parameter. In this case, we need to also increase ServerLimit to 500/20 i.e. MaxClients/ThreadsPerChild=25

Okay now you know the directives and how they work, the problem is how to calculate the directives. Let’s jump into calculating directive values.

You can use this shell script to determine an average amount of memory consumed by one Apache process. In addition to that it’ll show total amount of memory consumed by all Apache processes. Just unzip and execute with sh command. Accurate results will be shown when server is under heavy load.

The output

if in average, let’s assume that one Apache process consumes 50MB RAM and server has got RAM is 2048MB, and you want to leave 512MB for the rest of the processes, then:

So that’s how you configure Apache Multi-Processing Modules. If you have any questions let me know in the comments below. Your feedback is highly appreciated(happy-face).

Image Courtesy :

Be Sociable, Share!