What are Apache MPMs?

Apache: What are Apache MPMs?

Since Apache 2, Multi-Processing Modules (MPMs) have existed. They are modules that change how the Apache servers handles requests and listens to connections.

Common Apache MPMs include prefork, worker, and event. There are different MPMs for different operating systems - these three are for Unix based systems. See the list here for other operating system's MPMs.

How to decide what MPM your Unix-like system (i.e. Linux, BSD, Mac OS, etc) will use?

In the case of Unix, the decision as to which MPM is installed is based on two questions:

1. Does the system support threads?

2. Does the system support thread-safe polling (Specifically, the kqueue and epoll functions)?

If the answer to both questions is 'yes', the default MPM is event.

If The answer to #1 is 'yes', but the answer to #2 is 'no', the default will be worker.

If the answer to both questions is 'no', then the default MPM will be prefork.

In practical terms, this means that the default will almost always be event, as all modern operating systems support these two features.

How to check what MPM your installation of Apache is using?

Run the following command:

httpd -V | grep -i 'mpm'

The output from my Mac computer:

Server MPM:     prefork

The output from my linux VM:

Server MPM:     event

What is the prefork MPM? The preform module let's Apache work in a non-threaded, pre-forking way. Every one of the child processes that Apache has will have one single thread, and only processes one request at a time. It is the default type of MPM. This MPM is thread safe.

What is the Event Apache MPM? The Event MPM uses less resources than the other two described on this page. Each process can contain multiple threads. However, each thread can handle more than one task at a time. The event MPM works with Apache 2.2, however it is not fully compatible. It is recommended to use a minimum of Apache 2.4 when using the event MPM. (But there are plenty of high traffic sites using the event MPM and 2.2 without problems).

What is the worker mpm? The worker MPM lets Apache run as a multi threaded, multi process server. Each child process can have more than one thread. This means that Apache can handle a greater number of requests, while using fewer resources than the prefork MPM. The Worker MPM is commonly used with high traffic web servers on more recent versions of Apache. This MPM is not thread safe.

webdevetc profile pic

I am a 29 year old backend web developer from London, mostly focusing on PHP and Laravel lately. This (webdevetc.com) is my blog where I write about some web development topics (PHP, Laravel, Javascript, and some server stuff). contact me here.


Comments and discussion about What are Apache MPMs?

Found this interesting? Maybe you want to read some more in this series?

Or see other topics in the Apache language

Or see other languages/frameworks:
PHP Laravel Composer Apache CentOS and Linux Stuff WordPress General Webdev and Programming Stuff JavaScript
Or see random questions

How to hide the server signature (hide Apache info) from HTTP headers with .htaccess

How to block IPv6 IP addresses in .htaccess

How can you check if a variable is alphanum (alphanumeric, letters and numbers only) in PHP?

How to block multiple IP addresses in .htaccess

How to sort an array of dates and times?

How to find the average value of items in a Laravel Collection?

How to set up custom error pages in .htaccess for your Apache server (ErrorDocument)

How to increment a value in the database

How to view all installed PHP modules?

How to see all of the options for an artisan command?