How to Use Apache MPM prefork on your server

Apache (HTPD) is very popular and widely deployed Linux web server around the world. Default server comes with multiple modules. The term MPM is used for multiprocessing module. We can check for default mpm by running this command “httpd -l”

Prefork MPM

This handles apache requests just like previous Apache versions. As the name suggests it will pre-fork necessary child process while starting Apache. It is suitable for all those website hosting which don’t want to thread for compatibility. i.e for non-thread-safe libraries. This is known as one of the best MPM for dividing each incoming HTTP request.

How does it work?

One single control (master) process is responsible for launching multiple child processes which serve incoming HTTP requests. Apache always tries to maintain spare (not-in-use) server processes, which stand ready to serve the next incoming requests. By this way, clients do not need to wait for new child processes to be forked before their requests can be served.

We can adjust this spare process through the Apache configuration. Default settings are usually enough for a small number of traffic. One can always tweak those Directives / Values as per their requirements.

Pre-Fork is the default module given by Apache.

*Prefork MPM

*StartServers: Number of server processes to start.

*MinSpareServers: Minimum number of server processes which are kept spare on the server.

*MaxSpareServers: Max number of server processes which are kept spare on the server.

*ServerLimit: Max value for MaxClients for the lifetime of the server.

*MaxClients: Max number of server processes allowed to start.

*MaxRequestsPerChild: Max number of requests the server process serves.

What File to be updated and modified?


An example how to set Prefork MPM

<IfModule prefork.c>

StartServers 2

MinSpareServers 5

MaxSpareServers 20

ServerLimit 256

MaxClients 256

MaxRequestsPerChild 0


KeepAlive Off

One the files have been modified. Please restart the apache service by using the below command.

service httpd restart