# Multi-Processing Module Common Directives

This file documents directives that are implemented by more than one multi-processing module (MPM).

## Directives

- CoreDumpDirectory
- PidFile
- LockFile
- MaxClients
- MaxRequestsPerChild
- MaxSpareThreads
- MinSpareThreads
- ScoreBoardFile
- StartServers
- ThreadsPerChild

## CoreDumpDirectory directive

Syntax: CoreDumpDirectory directory
Default: the same location as ServerRoot
Context: server config
Status: MPM
Module: mpmt_pthread, prefork

This controls the directory to which Apache attempts to switch before dumping core. The default is in the ServerRoot directory, however since this should not be writable by the user the server runs as, core dumps won't normally get written. If you want a core dump for debugging, you can use this directive to place it in a different location.

## PidFile directive

Syntax: PidFile filename
Default: `PidFile logs/httpd.pid`
Context: server config
Status: MPM
Module: mpmt_pthread, prefork

The PidFile directive sets the file to which the server records the process id of the daemon. If the filename does not begin with a slash (/) then it is assumed to be relative to the ServerRoot.

It is often useful to be able to send the server a signal, so that it closes and then reopens its ErrorLog and TransferLog, and re-reads its configuration files. This is done by sending a SIGHUP (kill -1) signal to the process id listed in the PidFile.

The PidFile is subject to the same warnings about log file placement and security.

## LockFile directive

Syntax: LockFile filename
Default: `LockFile logs/accept.lock`
Context: server config
Status: MPM
Module: mpmt_pthread, prefork

The LockFile directive sets the path to the lockfile used when Apache is compiled with either USE_FCNTL_SERIALIZED_ACCEPT or USE_FLOCK_SERIALIZED_ACCEPT. This directive should normally be left at its default value. The main reason for changing it is if the `logs` directory is NFS mounted, since the lockfile must be stored on a local disk. The PID of the main server process is automatically appended to the filename.

SECURITY: It is best to avoid putting this file in a world writable directory such as `/var/tmp` because someone could create a denial of service attack and prevent the server from starting by creating a lockfile with the same name as the one the server will try to create.

## MaxClients directive

Syntax: MaxClients number
Default: `MaxClients 8` (with threads) `MaxClients 256` (no threads)
Context: server config
Status: MPM
Module: mpmt_pthread, prefork

The MaxClients directive sets the limit on the number of child processes that will be created to serve requests. When the server is built without threading, no more than this number of clients can be served simultaneously. To configure more than 256 clients, you must edit the `HARD_SERVER_LIMIT` entry in `mpm_default.h` and recompile.

Any connection attempts over the MaxClients limit will normally be queued, up to a number based on the ListenBacklog directive. Once a child process is freed at the end of a different request, the connection will then be serviced.

When the server is compiled with threading, then the maximum number of simultaneous requests that can be served is obtained from the value of this directive multiplied by ThreadsPerChild.

## MaxRequestsPerChild directive

Syntax: MaxRequestsPerChild number
Default: `MaxRequestsPerChild 10000`
Context: server config
Status: MPM
Module: mpmt_pthread, prefork

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.

Setting MaxRequestsPerChild to a non-zero limit has two beneficial effects:

- it limits the amount of memory that process can consume by (accidental) memory leakage;
- by giving processes a finite lifetime, it helps reduce the number of processes when the server load reduces.

NOTE: For KeepAlive requests, only the first request is counted towards this limit. In effect, it changes the behavior to limit the number of connections per child.

## MaxSpareThreads directive

Syntax: MaxSpareThreads number
Default: `MaxSpareThreads ??`
Context: server config
Status: core
Module: mpmt_pthread

Content needed here!

See also MinSpareThreads and StartServers.

## MinSpareThreads directive

Syntax: MinSpareServers number
Default: `MinSpareServers ???`
Context: server config
Status: core
Module: mpmt_pthread

fix me

The MinSpareServers directive sets the desired minimum number of idle child server processes. An idle process is one which is not handling a request. If there are fewer than MinSpareServers idle, then the parent process creates new children at a maximum rate of 1 per second.

Tuning of this parameter should only be necessary on very busy sites. Setting this parameter to a large number is almost always a bad idea.

This directive has no effect on Microsoft Windows.

See also MaxSpareThreads and StartServers.

## ScoreBoardFile directive

Syntax: ScoreBoardFile filename
Default: `ScoreBoardFile logs/apache_status`
Context: server config
Status: MPM
Module: mpmt_pthread, prefork

The ScoreBoardFile directive is required on some architectures to place a file that the server will use to communicate between its children and the parent. The easiest way to find out if your architecture requires a scoreboard file is to run Apache and see if it creates the file named by the directive. If your architecture requires it then you must ensure that this file is not used at the same time by more than one invocation of Apache.

If you have to use a ScoreBoardFile then you may see improved speed by placing it on a RAM disk. But be careful that you heed the same warnings about log file placement and security.

See Also: Stopping and Restarting Apache

## StartServers directive

Syntax: StartServers number
Default: `StartServers 5`
Context: server config
Status: MPM
Module: mpmt_pthread, prefork

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.

See also MinSpareThreads and MaxSpareThreads.

## ThreadsPerChild

Syntax: ThreadsPerChild number
Default: `ThreadsPerChild 50`
Context: server config
Status: Base
Module: mpmt_pthread

This directive sets the number of threads created by each child process.