MPM stands for multiprocessing module. We can see the default mpm using the command ” httpd -l ”
Apache 2 is mainly comes with the following MPM’s
prefork
worker
mpm_winnt
This Multi-Processing Module is optimized for Windows NT.
mpm_netware
Multi-Processing Module implementing an exclusively threaded web server optimized for Novell NetWare
1) Prefork MPM
prefork mpm handles requests just like apche 1.3. As the name implies this will pre fork necessary child process while starting apache. It is suitable for websites which avoids threading for compatibility for non-thread-safe libraries . It is also known as the best mpm for isolating each request.
Working : –
A single control process is responsible for launching child processes which listen for connections and serve them when they arrive. Apache always tries to maintain several spare or idle server processes, which stand ready to serve incoming requests. In this way, clients do not need to wait for a new child processes to be forked before their requests can be served.
We can adjust this spare process through the apche conf. For a normal server which is having 256 simultaneous connections can use the default prefork settings.
Perfork is the default module given by apache.
# StartServers: number of server processes to start
# MinSpareServers: minimum number of server processes which are kept spare
# MaxSpareServers: maximum number of server processes which are kept spare
# MaxClients: maximum number of server processes allowed to start
# MaxRequestsPerChild directive sets the limit on the number of requests that an individual child server process will handle. After MaxRequestsPerChild requests, the child process will die. If MaxRequestsPerChild is 0, then the process will never expire
2) Worker MPM
This Multi-Processing Module (MPM) implements a hybrid multi-process multi-threaded server. By using threads to serve requests, it is able to serve a large number of requests with fewer system resources than a process-based server.
The most important directives used to control this MPM are ThreadsPerChild, which controls the number of threads deployed by each child process and MaxClients, which controls the maximum total number of threads that may be launched.
Advantage : Memory usage and performanance wise its better than prefork
Disadvantage : worker will not work properly with languages like php
Working : –
A single control process (the parent) is responsible for launching child processes. Each child process creates a fixed number of server threads as specified in the ThreadsPerChild
directive, as well as a listener thread which listens for connections and passes them to a server thread for processing when they arrive.
Apache always tries to maintain a pool of spare or idle server threads, which stand ready to serve incoming requests. In this way, clients do not need to wait for a new threads or processes to be created before their requests can be served. The number of processes that will initially launched is set by the StartServers
directive. During operation, Apache assesses the total number of idle threads in all processes, and forks or kills processes to keep this number within the boundaries specified by MinSpareThreads
and MaxSpareThreads
. Since this process is very self-regulating, it is rarely necessary to modify these directives from their default values. The maximum number of clients that may be served simultaneously (i.e., the maximum total number of threads in all processes) is determined by the MaxClients
directive. The maximum number of active child processes is determined by the MaxClients
directive divided by the ThreadsPerChild
directive
You can refer more about these multiprocessing modules here :Apace Modules
Recent Comments