Apache General Apache Tips Cheatsheet
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
If The answer to #1 is 'yes', but the answer to #2 is 'no', the default will be
If the answer to both questions is 'no', then the default MPM will be
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.