Friday, October 18, 2019

Optimize Apache Performance in CentOS 7

 Optimize Apache Performance in CentOS 7

Requirements:

  • A server running CentOS v.7
  • Apache installed and running


MaxKeepAliveRequests :-

#sudo nano /etc/httpd/conf/httpd.conf
or
#sudo vi /etc/httpd/conf/httpd.conf

And Add the following line:

MaxKeepAliveRequests 500

KeepAliveTimeout :-

#sudo nano /etc/httpd/conf/httpd.conf
or
#sudo vi /etc/httpd/conf/httpd.conf

Add the following line:

KeepAliveTimeout 5

KeepAlive :-

#sudo nano /etc/httpd/conf/httpd.conf
or
#sudo vi /etc/httpd/conf/httpd.conf

Add the following line:

KeepAlive on

Configure MPM Prefork :-

One of the reason of Apache performance is that Apache having trouble coping with the load.
The Apache MPM (Multi-Processing Module) can help.

mpm_prefork_module is included and enabled in the default Apache installation on CentOS 7. To confirm this run the following command:

# sudo apachectl -t -D DUMP_MODULES |grep mpm
You should see mpm_prefork_module (shared) if mod_deflate is installed and enabled.

#sudo nano /etc/httpd/conf/httpd.conf
or
#sudo vi /etc/httpd/conf/httpd.conf

Add the following lines:

KeepAlive Off
<IfModule prefork.c>
   StartServers        5
   MinSpareServers     5
   MaxSpareServers     10
   MaxClients          150
   MaxRequestsPerChild 3000
</IfModule>

Save and close the file, then restart Apache to reflect these changes.

# sudo apachectl restart

0 comments: