top of page
Search
understandingdevop

Multiprocessing models in apache web server, MPM prefork and MPM worker

Let's talk about these two models, which are used for multiprocessing in the apache web server.

MPM Prefork.

If you don't specify which multiprocessing model to be used in apache configuration, by default apache will use MPM prefork for multiprocessing.

MPM prefork model is resource-intensive because it follows the process per request pattern while serving the request. Here is how it works.

When we start the apache web server, it creates a parent process and the parent process creates multiple child processes. So now whenever the client requests the web server your child process will serve the response to the client's request. Each child process handles each client. So apache maintains idle child processes before requests arrive, so that when a request arrives it won't take time to create a process and serve a faster response to the client.

Now let's say you have a lot of requests coming at once, this will end up creating many child processes by apache for serving a request, which will cause heavy resource utilization. Each process will consume some memory and CPU.




MPM Worker

MPM Worker model can serve a large number of requests in a very limited number of resources compared to MPM prefork. This multiprocessing model works on thread. When we start the apache server, same as in MPM prefork, it creates a parent apache process, which will create multiple child processes, and here those multiple child processes create multiple threads that will actually serve the client's request. This model works on Thread per request.

There is a directive inside apache config file /etc/httpd/conf/httpd.conf called “StartServers” which says how many child processes will be there when apache starts.

The child process handles requests with the help of a fixed number of threads inside them which is specified by the argument “ThreadsPerChild” in the config file.




2 views0 comments

Comments


Post: Blog2_Post
bottom of page