The
Multi-Processing modules also called as MPM are the ones that are responsible
for binding to network ports on a machine, accepting requests and dispatching
children to handle the requests. So when ever a request comes to the Apache
server the MPM modules takes the request and assigns one of its Child to the
request for processing.
One important
thing about this that only one MPM module can be active at any time in the
HTTPD server. This is like any other Apache module but only one will be loaded
at time.
The reason why
MPM came into existence is to allow different ways that a server is build to
handle HTTP requests within the Computing Constrains.
How does this Work?
There exists a
Single Control Master process which is responsible for launching multiple Child
process which takes the incoming HTTP requests for processing. Apache always
tried to maintain several spare ( not-in-use ) process which will be ready for
serving incoming requests. In this way client does not need to wait for child
Processed to be forked before their requests can be severed.
Installing MPM
As said earlier
only one MPM can be active at a time. The Installation of MPM can be done when
we are building the Apache HTTPD server from source by passing an argument
--with-MPM=<Module
Name>
Available MPM
Apache Server
supports multiple types of MPM. Of all the available the important ones are
Prefork and Worker.
By default
Prefork modules is being used as the default one for Apache. There are certain
major differences in selecting the MPM for Production uses
Apache Prefork MPM - This
Multi-Processing Module (MPM) implements a non-threaded, pre-forking web server
that handles requests. This is appropriate for web sites that need to avoid
threading for compatibility with non-thread safe libraries. This is said to be
the best MPM for isolating requests so that problem with a Single request does
not effect any others.
This 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 less system
resources than a process-based server. This also keeps spare process with threads in
order to handle more load of requests
Apache Worker MPM – This MPM is best used threaded
environment. This is used with Apache with modules loaded in do not have thread
safety issues. However, creating processes on Linux is generally fast enough
that you don't need to use worker. The worker MPM really shows off it's value
on platforms that have very heavy-weight processes, such as AIX.
The Major
Differences are
Prefork – uses
multiple Child Process with one thread each and each process handles one
connection at a time. Each request gets its own Memory-separated Process
Worker – uses
multiple Child Process with many thread each. Each thread handles one
Connection at a time. This is considered to be faster than the Prefork MPM.
How to find which MPM is loaded
In order to find
which MPM the Current HTTPD process is using, we can run the command
[root@localhost ]
httpd –V
…
Server MPM:
Prefork
Configurations Files
The configuration
of Prefork or Worker MPM exists in the conf.modules.d/ location in the Apache
location with name mpm.conf
We can un-comment
the LoadModule of the MPM we want to use.
Hope this Helps,
More to come on configuring the MPM
No comments :
Post a Comment