Last updated on August 10th, 2020 at 03:05 am
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.
How Many Requests Can Apache Handle Per Second
By default, Apache Request limit is 160 requests per second, that is, Apache can handle up to 160 requests per second, without any modification.
How To Increase Apache Requests Per Second
Here are the steps 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
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.
Ubuntu/Debian: use a2dismod
/ a2enmod
to disable mpm_prefork and enable mpm_worker
$ a2dismod mpm_prefork $ a2enmod mpm_worker
Bonus Read : How to Install mod_wsgi in Apache on Ubuntu
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
Bonus Read : How to Increase Max Connections in Apache
You will see the following lines
StartServers 5 MinSpareServers 5 MaxSpareServers 10 MaxRequestWorkers 150 MaxConnectionsPerChild 0
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.
Let’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
Bonus Read : How to Increase Max URL Length in Apache
3. Restart Apache Server
Restart Apache web server to Apply changes.
Ubuntu/Debian
$ sudo service apache2 restart
CentOS/Redhat/Fedora
$ sudo service httpd restart
Hopefully, this article will help you increase Apache requests per second.
Ubiq makes it easy to visualize data in minutes, and monitor in real-time dashboards. Try it Today!
Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI & software development.