We want the value of MaxClients to be as small as
possible, because in this way we can limit the resources used by the
server's children. Since we can restrict each
child's process size, as discussed later, the
calculation of MaxClients is straightforward:
So if we have 400 MB for the mod_perl server to use, we can set
MaxClients to 40 if we know that each child is
limited to 10 MB of memory.
where Total_RAM is of course the estimated total
RAM available to the web server.
Let's perform some calculations, first with sharing
in place:
Total_RAM = 500Mb
Max_Process_Size = 10Mb
Min_Shared_RAM_per_Child = 4Mb
then with no sharing in place:
With sharing in place, if your numbers are similar to the ones in our
example, you can have 64% more servers without buying more RAM (82
compared to 50).
If you improve sharing and the sharing level is maintained throughout
the child's life, you might get:
Total_RAM = 500Mb
Max_Process_Size = 10Mb
Shared_RAM_per_Child = 8Mb
Here we have 392% more servers (246 compared to 50)!
There is one more nuance to remember. The number of requests per
second that your server can serve won't grow
linearly when you raise the value of MaxClients.
Assuming that you have a lot of RAM available and you try to set
MaxClients as high as possible, you will find that
you eventually reach a point where increasing the
MaxClients value will not improve performance.
The more clients that are running, the more CPU time will be required
and the fewer CPU time slices each process will receive. The response
latency (the time to respond to a request) will grow, so you
won't see the expected improvement.
Let's explore these issues.