The popularity of Apache web server in the world is unquestionable. System administrator likes it due to its modular design. On top of this, Apache 2 introduced Multi-Processing Modules or MPMs that change the basic functionality of the web server.
What is MPMs?
It is a core module of Apache. MPM handle important core tasks such as creating network connections (binding to ports), listening for and accepting requests from clients (browsers) and creating child processes or threads to handle the requests. Because these core tasks must be handled the same way for every request, you can only have one MPM loaded at the time. EasyApache 4 prevents the installation of more than one MPM concurrently.
At the end of the startup phase, after the configuration has been read, after the configuration has been read, Apache’s general control is passed to a process management module i.e. Multi-Processing Module.
One MPM is an interface between the running Apache server and underlying OS. Its main role is to optimize Apache according to the platform on which the server is running.
- MPM Prefork: it is an un-oriented model thread, strongly resembling the mode of operation of the Apache servers 1.x. This means that each child Apache process includes a single thread and handles one request at a time. Due to this kind of nature, it consumes more resources than the oriented threaded MPM i.e. Worker and Event.
Note: Prefork is the default MPM, so if there is no MPM is designated in EasyApache, Prefork will be selected by default. However, it’s still the best option in case Apache has to use un-oriented thread-safe libraries such as mod_php (DSO), and is a perfect choice if isolation of processes is important.
- MPM Worker: This is an oriented thread. It has greater flexibility and adapts much better to the demand. It is particularly better than the previous model, especially with certain types of application. It actually turns Apache into a multi-process and multi-threaded web server.As opposite to Prefork, here, each child process can have multiple threads. MPM Worker can handle more requests without consuming too much resources.Therefore, it’s generally recommended for high-traffic servers running Apache versions prior to 2.4. However, it suffers due to the incompatibility with non-thread safe libraries. So if you need to run something which isn’t thread safe, then Prefork is the best option to stick with.
- MPM Event: It is Event MPM where each process can also contain multiple threads, but unlike, Worker, each is proficient of more than just one task. In addition, Apache has the lowest resource requirements when used under the Event MPM. However, it’s supported only on servers that running on Apache 2.4. If it’s Apache 2.2, then Event is considered experimental and is incompatible with some modules on older Apache versions.On the other hand, on high traffic Apache 2.2 servers where Apache has proficient issues with memory, upgrading Apache to take benefit of the Event MPM can return substantial results.
- MPM ITK: The multi-processing module, which is the component of Apache that manages the simultaneous connections, in terms of process or thread. By using this approach it keeps an advantage over Worker and Prefork MPM, because one of the limitations of traditional MPM is that they use the same uid and gid, defined to handle queries from all vhosts (virtual host).
Here, MPM ITK allows choosing a different uid: gid for virtual host (vhost) without using CGI or the suexec or suphp modules, which is extremely convenient for shared hosting environment as well as in some practical cases. On the security side, it allows isolating the configuration of each vhost directly in its configuration file. However, the main limitation of the ITK is its performance, because it creates and then destroys a process for each query, which apparently degrades the performance, especially compared to Prefork or Worker. Although, ITK remains efficient than the suexec or suphp modules.
If performance is essential to you, then it will be good to turn to the pre-user mpm which does the same job by taking advantage of the threads but it requires much more configuration efforts or the FastCGI solution.
- The Other MPMs: There are other experimental MPMs also present, but we recommend not use them in production environment. It’s good to use them in test environment, as they are experimental, which means no guarantees that they will work as expected.