The apache2 setting in prefork mode and worker mode

In prefork mode

Configuration example:

<IfModule mpm_prefork_module>
    ServerLimit          128
    MaxClients           128
    MinSpareServers        5
    MaxSpareServers       10
    MaxRequestsPerChild 1000
</IfModule>

Information:

  • ServerLimit 128 ⇔ We start at max 128 processes. The number of processes launched is dynamically adjusted, apache will start 128 processes only if it is necessary.
  • MaxClients 128 ⇔ 128 simultaneous connections are allowed (MaxClients = ServerLimit)
  • MinSpareServers 5 ⇔ Apache is asked to keep at least 5 processes waiting for connection.
  • MaxSpareServers 10 ⇔ Apache is asked not to keep more than 10 processes waiting for connection.
  • MaxRequestsPerChild 1000 ⇔ After 1000 connections on a child, we kills it (allows to tolerate any memory leaks)

In worker mode

Configuration example:

<IfModule mpm_worker_module>
    ServerLimit            2
    ThreadsPerChild       64
    MaxClients           128
    MinSpareThreads       25
    MaxSpareThreads       75
    MaxRequestsPerChild 1000
</IfModule>

Information:

  • ServerLimit 2 ⇔ We start at max 2 processes. The number of processes launched is dynamically adjusted, apache will launch 2 processes only if it is necessary.
  • ThreadsPerChild 64 ⇔ We launch 64 threads for each process.
  • MaxClients 128 ⇔ 128 simultaneous connections are allowed (MaxClients = ServerLimit * ThreadsPerChild)
  • MinSpareThreads 25 ⇔ Apache is asked to keep at least 25 threads waiting for connection.
  • MaxSpareThreads 75 ⇔ Apache is asked not to keep more than 25 threads waiting for connection.
  • MaxRequestsPerChild 1000 ⇔ After 1000 connections on a child, we kills it (allows to tolerate any memory leaks).