Three important Apache settings which can be tuned for improved performance are the MaxKeepAliveRequests, KeepAlive, and KeepAliveTimeout.
MaxKeepAliveRequests sets the maximum number of requests to accept per connection. The higher this number, the better the performance of the server, up to a point. The recommended value is 500.
KeepAlive sets whether Apache will allow more than one request per connection. This is set to Off by default on CentOS 7. High-traffic servers can see a significant performance improvement by changing this setting to On.
KeepAliveTimeout sets the number of seconds Apache will wait for a new request from a connection before it closes the connection. This number should be kept low. The recommended value is between 1 and 5.
To change these settings, open the main Apache configuration file for editing:
- CentOS 7:sudo nano /etc/httpd/conf/httpd.conf
- Ubuntu 16.04:sudo nano /etc/apache2/apache2.conf
Add the following lines to this file, customizing the values to your preference: