Apache MPM Worker
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. However, 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 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.
Configuration
MaxClients
Maximum number of connections that will be processed simultaneously
- Default: 150 (Gentoo)
MaxClients
restricts the total number of threads that will be available to serve clients.
For hybrid MPMs the default value is 16 (ServerLimit
) multiplied by the value of 25 (ThreadsPerChild
). Therefore, to increase MaxClients
to a value that requires more than 16 processes, you must also raise ServerLimit
.
MaxRequestsPerChild
Limit on the number of requests that an individual child server will handle during its life
- Default: 0 (10000 in Gentoo)
The 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.
MaxSpareThreads
Maximum number of idle threads
- Default: 250 (75 in Gentoo)
For worker, the default is MaxSpareThreads 250
(75 in Gentoo). These MPMs deal with idle threads on a server-wide basis. If there are too many idle threads in the server then child processes are killed until the number of idle threads is less than this number.
The value must be greater or equal than the sum of MinSpareThreads
and ThreadsPerChild
.
See also MinSpareThreads
and StartServers
.
MinSpareThreads
Minimum number of idle threads available to handle request spikes
- Default: 75 (Gentoo: 25)
Minimum number of idle threads to handle request spikes.
worker
uses a default of MinSpareThreads 75
and deal with idle threads on a server-wide basis. If there aren't enough idle threads in the server then child processes are created until the number of idle threads is greater than number.
See also MaxSpareThreads
and StartServers
ServerLimit
Upper limit on configurable number of processes
- Default: Unset in Gentoo
For the worker
MPM, this directive in combination with ThreadLimit
sets the maximum configured value for MaxClients
for the lifetime of the Apache process.
With worker
use this directive only if your MaxClients
and ThreadsPerChild
settings require more than 16 server processes (default). Do not set the value of this directive any higher than the number of server processes required by what you may want for MaxClients
and ThreadsPerChild
.
StartServers
Number of child server processes created at startup
- Default: 3 (2 in Gentoo)
The StartServers
directive sets the number of child server processes created on startup. As the number of processes is dynamically controlled depending on the load, there is usually little reason to adjust this parameter.
StartThreads
Number of threads created on startup
- Default: Unset in Gentoo
Number of threads created on startup. As the number of threads is dynamically controlled depending on the load, there is usually little reason to adjust this parameter.
ThreadLimit
Sets the upper limit on the configurable number of threads per child process
- Default: 64 (Unset in Gentoo)
This directive sets the maximum configured value for ThreadsPerChild
for the lifetime of the Apache process.
Special care must be taken when using this directive. If ThreadLimit
is set to a value much higher than ThreadsPerChild
, extra unused shared memory will be allocated. If both ThreadLimit
and ThreadsPerChild
are set to values higher than the system can handle, Apache may not start or the system may become unstable. Do not set the value of this directive any higher than your greatest predicted setting of ThreadsPerChild
for the current run of Apache.
ThreadsPerChild
Number of threads created by each child process
- Default: 25
This directive sets the number of threads created by each child process. The child creates these threads at startup and never creates more.
Using an MPM like worker, where there are multiple child processes, the total number of threads should be high enough to handle the common load on the server.