The goal of this doc is to give you some tips to help tuning the worker MPM of the Apache web server.
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 less system resources than a process-based server. Yet it retains much of the stability of a process-based server by keeping multiple processes available, each with many threads.
The most important directives used to control this MPM are ServerLimit (default is 16), which controls the max number of process started by Apache, ThreadsPerChild (default is 25), which controls the number of threads deployed by each child process and MaxClients (default is 256), which controls the maximum total number of threads that may be launched and which can't be greater than (ServerLimit * ThreadsPerChild). The memory impact
The first thing to keep in mind, is that changing the value of MaxClients will have a direct impact on the amount of memory your Apache instance will use. To give you an idea, each process will use around 15MB of memory (depending on the modules loaded) and each thread will use around 128KB. Has you can see the worker parameters and the amount of memory used are tighted together and changing one value will change all the others. So the first thing to do is to make a choice on which value among MaxClients and Memory is the most important for you, fix that value and determine the other value with the following rules.
All calculation rules are deduced from the following assertions :
Memory = ServerLimit * ProcessSize + ThreadSize * ThreadsPerChild
MaxClient = ServerLimit * ThreadsPerChild
Find MaxClient with fixed Memory size
MaxClient = (Memory * ThreadsPerChild) / (ProcessSize + ThreadSize * ThreadsPerChild)
Find max Memory usage with fixed MaxClient
Memory = MaxClient(ProcessSize + ThreadSize * ThreadsPerChild) /
ThreadsPerChild
Set all other values
As Threads are much more light than processes, we'll assume that we always set TheadsPerChild to its maximum value.
ThreadsPerChild = 64
With the second assertion we can deduce the ServerLimit value :
ServerLimit = MaxClient / 64