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

What are Template literals (Template strings) in JS?

How to Force www or non-www in htaccess

A list of operators on Eloquent's where() method

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

How to sort an array of dates and times?

What is the max size, by default, of GET variables?

How to find the intersection (same values) from two arrays?

How to use Anonymous classes in PHP 7?

An overview of every main PHP array function

How to select what columns to return when calling ::all()