GoranStimac.com
How Can I Help
Stay Informed
Let's Connect

©2018 - 2021 Goran Štimac. All rights reserved.
v1.28_b2021-09-14

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.
1touch /etc/httpd/conf.d/z-optimize.conf
  1. Open file for editing with your favorite editor:
1vim /etc/httpd/conf.d/z-optimize.conf
  1. Input necessary directive change, using IfModule statements for compatibility.

MPM Prefork example:

 1Timeout 30
 2<IfModule mpm_prefork_module>
 3    KeepAlive On
 4    MaxKeepAliveRequests 500
 5    KeepAliveTimeout 3
 6
 7    ServerLimit 23
 8    StartServers 12
 9
10    MinSpareServers 12
11    MaxSpareServers 23
12
13    MaxRequestWorkers 23
14    MaxConnectionsPerChild 10000
15</IfModule>

MPM Event example:

 1Timeout 30
 2<IfModule mpm_event_module>
 3    KeepAlive On
 4    MaxKeepAliveRequests 500
 5    KeepAliveTimeout 3
 6
 7    ThredsPerChild 25
 8    ServerLimit 23
 9    MaxRequestWorkers 400
10
11    StartServers 16
12    MinSpareThreads 200
13    MaxSpareThreads 400
14    
15    MaxConnectionsPerChild 10000
16</IfModule>

MPM Worker example:

 1Timeout 30
 2<IfModule mpm_worker_module>
 3    KeepAlive On
 4    MaxKeepAliveRequests 500
 5    KeepAliveTimeout 1
 6
 7    ThredsPerChild 25
 8    ServerLimit 23
 9    MaxRequestWorkers 400
10
11    StartServers 16
12    MinSpareThreads 200
13    MaxSpareThreads 400
14    
15    MaxConnectionsPerChild 10000
16</IfModule>
  1. Save the file
  2. Reload Apache
1service 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
1cp -p /etc/apache2/apache2.conf{,.bak.$(date +%F_%H%M%S)}
2ls -lah /etc/apache2/apache2.conf*
  1. Open file for editing with your favorite editor
1vim /etc/apache2/apache2.conf
  1. Append the necessary directive changes to the very bottom of the config file

MPM Prefork example:

 1Timeout 30
 2<IfModule mpm_prefork_module>
 3    KeepAlive On
 4    MaxKeepAliveRequests 500
 5    KeepAliveTimeout 3
 6
 7    ServerLimit 23
 8    StartServers 12
 9
10    MinSpareServers 12
11    MaxSpareServers 23
12
13    MaxRequestWorkers 23
14    MaxConnectionsPerChild 10000
15</IfModule>

MPM Event example:

 1Timeout 30
 2<IfModule mpm_event_module>
 3    KeepAlive On
 4    MaxKeepAliveRequests 500
 5    KeepAliveTimeout 3
 6
 7    ThredsPerChild 25
 8    ServerLimit 23
 9    MaxRequestWorkers 400
10
11    StartServers 16
12    MinSpareThreads 200
13    MaxSpareThreads 400
14    
15    MaxConnectionsPerChild 10000
16</IfModule>

MPM Worker example:

 1Timeout 30
 2<IfModule mpm_worker_module>
 3    KeepAlive On
 4    MaxKeepAliveRequests 500
 5    KeepAliveTimeout 1
 6
 7    ThredsPerChild 25
 8    ServerLimit 23
 9    MaxRequestWorkers 400
10
11    StartServers 16
12    MinSpareThreads 200
13    MaxSpareThreads 400
14    
15    MaxConnectionsPerChild 10000
16</IfModule>
  1. Save the file
  2. Reload Apache
1apache2ctl reload
Share:

comments powered by Disqus
Hostinger Affiliate

Let’s Talk About Your Needs

Free Consultation