Hey everyone and welcome back. In the previous nugget we had just discussed the concept of
modules with respect to our Apache server. Now what I want to talk to you about is something
called multi processing and actually more specifically something called MPM. These are
multi processing modules. Here is the deal. Imagine we have our little Apache server right
here and it's super cool. It's got some really sleek web design going on. It's very very popular.
This would clearly not be the case if this was designed by me of course. You can imagine someone
more competent writing HTML and PHP designed this website. So we have one user called this person
user one accessing the website and they are happily getting that information back. No problem at all.
But word begins to spread that the website is so good that we have another user who also begins
to frequently visit the website. Now as this happens and we get more and more users and more
and more requests this actually begins to become problematic. Let me tell you why because here is
the deal on the Apache server as it stands we have a child process that has been spawned and this
is actually responsible for handling these particular requests. Now if someone is effectively
occupying and consuming these resources it's tying up this particular process such that when
additional users all try to access this website they cannot get access because the server is
preoccupied dealing with someone else. So clearly this is not desirable. It's not scalable. It's not
the way we want our website to run. So the solution that we want to be looking at is to be able to
create multiple processes within the server memory. So as opposed to having one child process we can
have multiple child processes meaning that we can ultimately have concurrent connections. So this
is super super useful because if we go back to our initial problem we have our Apache server and
we have all of these people who want to access this website. If we take say for example this
connection here and we deal with it within one child process and take this connection here and
deal with it with a second child process and this one again we can deal with all of these
connections together at once and no one here has to worry about getting delayed in their response
or even getting rejected in their response. So this is ultimately going to really drastically
improve the performance of our servers. Now as it pertains to these MPMs i.e. these multi-processing
modules we actually have different variants. So the first variant we have is one called the
pre fork multi-processing module. This is the most basic and simple module and it basically means
that for every child process we're going to have what is called a single thread. Now you don't have
to be too concerned about the intricacies of threading versus multi-processing but just understand
that we have a single thread per child process whereas with our second type of multi-processing
module we can have the worker npm. Now this basically makes the Apache server use multi-processing
and multi-threading so each child process can actually have multiple threads. Now again we
don't want to be getting too bogged down into the intricacies of what this actually means in the
deep details. At its core what this basically means is that things are going to be more efficient.
Basically the server is going to be capable of handling more requests while using fewer resources
so this is obviously a big big win. And the third npm is the event npm. This is similar to the worker
npm in that we can have multiple threads per each child process. So obviously we get this
additional efficiency as compared to the pre fork module. The difference here is that each of these
multiple threads can actually be working on different tasks. So as opposed to the threads
all working together doing the exact same thing with the event npm these threads can actually
be sparing out and doing different things. So that really is the high level overview of the
different modules we have available to us. So what I want to do now is I want to quickly look at
what we have running on our system right now. So we are in as we can see here the mods enabled
directory right here. If I do an ls and I happen to grip for npm for multi processing module we can
actually see here the module we're using is the pre fork. Like I say this is the default it is the
most basic module. Now let me show you what this configuration file actually looks like them. So
what I can say is sudo nano npm pre fork dot conf I'll type in my password. Now as we can see here
we have these different values. Now at the top it actually explains to us what these values actually
pertain to. So we can see here the start servers this is going to be the number of server processes
that we actually want to kick off. A very important one is our max request workers. This is the number
of processes allowed to start basically. So as it stands we can see here we have a maximum
of 150 server processes that can be running on our server right now. And as we can see here we
have additional values we can see the min spare servers the amount of processes to keep spare.
So the minimum we have spare is five and the maximum is going to be 10. So really for the purposes
of the examination we want to understand that we have the ability to handle multiple connections
in this rather elegant way. We can use multiprocessing modules and we do have different types of
multiprocessing module. We have the pre fork we have the worker and we have the event multiprocessing
modules. And with respect to whatever module we happen to be using like I say here I've got an
npmprefork.conf file but you may have if I go into my mods available and I do an ls-l and I
get it for mpm. We can actually see here I have worker configuration files as well as event
configuration files but notice they just simply are not enabled because the ones which are enabled
we can see are within the mod enabled directory which have the sim links pointing to these
particular configuration files. Ok doc so that is us for our introduction into
multiprocessing on Apache. I hope this has been informative for you and I'd like to thank you for viewing.