GoranStimac.com



Apache Performance Tuning: Configuring MPM Directives

In previous articles I was focused on defining and fitting MPM to match your environment. Building from our last tutorial we will be discussing specific details on how to adjust the previously mentioned Apache configuration directives on the CentOS and Ubuntu types of VPS servers.

  • CentOS 6/7 Servers
  • Ubuntu 14.04/16.04 LTS Servers

CentOS 6/7 Servers

On CentOS servers, Apache configuration files are located in /etc/httpd/.

  1. Log in to the server over SSH or FTP.
  2. First, create an optimization file. It’s necessary for the optimization file to be loaded last so that it will override all other previous settings. I suggest naming the file z-optimize.conf.
touch /etc/httpd/conf.d/z-optimize.conf
  1. Open file for editing with your favorite editor:
vim /etc/httpd/conf.d/z-optimize.conf
  1. Input necessary directive change, using IfModule statements for compatibility.

MPM Prefork example:

Timeout 30
<IfModule mpm_prefork_module>
    KeepAlive On
    MaxKeepAliveRequests 500
    KeepAliveTimeout 3

    ServerLimit 23
    StartServers 12

    MinSpareServers 12
    MaxSpareServers 23

    MaxRequestWorkers 23
    MaxConnectionsPerChild 10000
</IfModule>

MPM Event example:

Timeout 30
<IfModule mpm_event_module>
    KeepAlive On
    MaxKeepAliveRequests 500
    KeepAliveTimeout 3

    ThredsPerChild 25
    ServerLimit 23
    MaxRequestWorkers 400

    StartServers 16
    MinSpareThreads 200
    MaxSpareThreads 400
    
    MaxConnectionsPerChild 10000
</IfModule>

MPM Worker example:

Timeout 30
<IfModule mpm_worker_module>
    KeepAlive On
    MaxKeepAliveRequests 500
    KeepAliveTimeout 1

    ThredsPerChild 25
    ServerLimit 23
    MaxRequestWorkers 400

    StartServers 16
    MinSpareThreads 200
    MaxSpareThreads 400
    
    MaxConnectionsPerChild 10000
</IfModule>
  1. Save the file
  2. Reload Apache
service httpd restart

Ubuntu 14.04/16.04 LTS Servers

On Ubuntu servers, Apache configuration files are located in /etc/apache2/.

  1. Backup existing apache2.conf file
cp -p /etc/apache2/apache2.conf{,.bak.$(date +%F_%H%M%S)}
ls -lah /etc/apache2/apache2.conf*
  1. Open file for editing with your favorite editor
vim /etc/apache2/apache2.conf
  1. Append the necessary directive changes to the very bottom of the config file

MPM Prefork example:

Timeout 30
<IfModule mpm_prefork_module>
    KeepAlive On
    MaxKeepAliveRequests 500
    KeepAliveTimeout 3

    ServerLimit 23
    StartServers 12

    MinSpareServers 12
    MaxSpareServers 23

    MaxRequestWorkers 23
    MaxConnectionsPerChild 10000
</IfModule>

MPM Event example:

Timeout 30
<IfModule mpm_event_module>
    KeepAlive On
    MaxKeepAliveRequests 500
    KeepAliveTimeout 3

    ThredsPerChild 25
    ServerLimit 23
    MaxRequestWorkers 400

    StartServers 16
    MinSpareThreads 200
    MaxSpareThreads 400
    
    MaxConnectionsPerChild 10000
</IfModule>

MPM Worker example:

Timeout 30
<IfModule mpm_worker_module>
    KeepAlive On
    MaxKeepAliveRequests 500
    KeepAliveTimeout 1

    ThredsPerChild 25
    ServerLimit 23
    MaxRequestWorkers 400

    StartServers 16
    MinSpareThreads 200
    MaxSpareThreads 400
    
    MaxConnectionsPerChild 10000
</IfModule>
  1. Save the file
  2. Reload Apache
apache2ctl reload

Related Posts