How to Increase Apache Request Per Second ?

How to Increase Apache Request Per Second ?


By default, Apache web server is configured to support 160 requests per second. As your website traffic increases, Apache will start dropping additional requests and this will spoil customer experience. 

Here’s how to increase Apache requests per second.

1. Install MPM module

We need to install MPM Apache module to be able to increase Apache requests per second. You can use mpm_worker or mpm_event module for this, instead of mpm_prefork module which consumes a lot of memory.

You can easily install MPM module in Apache with following command

For CentOS7/RHEL7 : Adjust /etc/httpd/conf.modules.d/00-mpm.conf

Comment the line LoadModule mpm_prefork_module modules/mod_mpm_prefork.so by adding # in front of it.

Uncomment the line LoadModule mpm_worker_module modules/mod_mpm_worker.so by removing # in front of it.

For Ubuntu/Debian :  Use a2dismod / a2enmod to disable mpm_prefork and enable mpm_worker


2. Increase Max Connections in Apache


Open MPM configuration file:


CentOS/RHEL


$ sudo vi /etc/httpd/conf.modules.d/00-mpm.conf


Ubuntu/Debian


$ sudo vi /etc/apache2/mods-available/mpm_worker.conf


you will see the following lines


StartServers 5

MinSpareServers 5

MaxSpareServers 10

MaxRequestWorkers 150

MaxConnectionsPerChild 0


In case you do not see the configuration , It means Apache is using the default configuration. 


You can change them to the following configuration to increase max requests per second. The following configuration supports up to 8000 concurrent users


<IfModule mpm_worker_module>

        ServerLimit 250

        StartServers 10

        MinSpareThreads 75

        MaxSpareThreads 250

        ThreadLimit 64

        ThreadsPerChild 32

        MaxRequestWorkers 8000

        MaxConnectionsPerChild 10000

</IfModule>


You can also add the above lines to Apache web server configuration file, or Virtual host configuration file.


et’s quickly look at the parameters


Serverlimit – Maximum number of Apache processes


StartServers – Number of processes to start when you start running Apache


MinSpareThreads/MaxSpareThreads – Number of threads to keep idle without being killed


ThreadsPerChild – Number of threads per process


MaxRequestWorkers – Number of concurrent connections to be supported. This is the main directive that you need to change to increase max connections in Apache


MaxConnectionsPerChild – Number of connections to be handled by each child before it is killed

Open MPM configuration file:


To get the configurations to take effects , you have to restart the server. 


3. Testing if the configuration is working or not ?


To check if the above configurations are working fine or not. You need to check the running process. 
post restart you should see the 10 httpd process running. 

Please note , process may be come down if there is no enough traffic on Apache , and it will come up by itself when the load / traffic increases. 





Comments

  1. I liked your work and the way in which you have shared this article here about...about software developer.. It is a beneficial and helpful article for us. Thanks for sharing an article like this.

    ReplyDelete
  2. You've provided here with great substance. I'm happy that I came into this article because it has a wealth of useful information. I appreciate you sharing such an informative article.Offshore Java Developers

    ReplyDelete

Post a Comment

Popular Posts

how to clear dispatcher cache in aem ?

AEM Security Headers

How Does S3 works with AEM ?

AdobeDispatcherHacks ".statfile"

How to prevent DDoS in Apache ?

Configure/Decoding AEM AuditLogs

curl command AEM package filter addition creation

How to configure s3 in AEM ?

OakAccess0000: Access denied