KeepAlive MaxKeepAliveRequests Apache optimize


MaxKeepAliveRequests
MaxKeepAliveRequests limits the number of requests allowed per connection. It is used to control persistent connections. In Ubuntu, the default value of MaxKeepAliveRequests is 100. You can change it to any value you desire. The recommended value of MaxKeepAliveRequests is between 50 and 75.
You can change this value by editing the Apache configuration file.
sudo nano /etc/httpd/httpd.conf
Change the value from 100 to 60.
MaxKeepAliveRequests 60
Save the file and restart Apache.
sudo /etc/init.d/httpd restart
KeepAliveTimeout
KeepAliveTimeout defines how long the server waits for the new request from connected clients. Setting KeepAliveTimeout to a high value may cause performance issues in a heavily loaded web server. In Ubuntu, the default value of KeepAliveTimeout is 15. The recommended value of KeepAliveTimeout is between 1 and 5.
You can change this value by editing the Apache configuration file.
sudo nano /etc/httpd/httpd.conf
Change the value from 15 to 3.
KeepAliveTimeout 3
Save the file and restart Apache.
MaxClients
It sets the limit on the number of simultaneous connections that will be served. Every new connection request will be queued up after this limit. Once a process is freed, then the queued connection will be served. In Ubuntu, the default MaxClients value is 250. It is recommended to keep this value at 150.
You can change this value by editing the “mpm_prefork.conf” file.
sudo nano /etc/httpd/mods-available/mpm_prefork.conf
Change the value from 250 to 150.
MaxClients 150
Save the file and restart Apache.
MaxConnectionsPerChild
It is used to recycle processes. When this limit is set to 0, an unlimited amount of requests are allowed per process. MaxConnectionsPerChild sets the limit on the number of requests that an individual child process will handle. After it reaches the specified limit, the child process will die. In Ubuntu, the defaultMaxConnectionsPerChild value is 100.
The recommended values for this setting are:
·        virtualized server 300
·        server with 1-4GB RAM 500
·        server with 4+GB RAM 1000
You can change this value by editing the “mpm_prefork.conf” file.
sudo nano /etc/httpd/mods-available/mpm_prefork.conf
Change the value from 100 to 300.
MaxConnectionsPerChild 300
Save the file and restart Apache.
KeepAlive
By default, this setting is set to On in Ubuntu. When the Apache server is getting requests from hundreds and thousands of IPs at once, then this setting should be Off. It is recommended to disable this setting to increase connection throughput.
You can disable this setting by editing the Apache configuration file.
sudo nano /etc/httpd/httpd.conf
Change the value from On to Off.
KeepAlive Off
Save the file and restart Apache.
MinSpareServers and MaxSpareServers
It sets the desired minimum and maximum number of idle child server processes. It controls how many unused child-processes Apache will keep alive while waiting for more requests to put them to use. Each child-process consumes resources, so if you set the MaxSpareServers value too high, then it can cause resource problems.
The recommended values for MinSpareServers are:
·        virtualized server 5
·        server with 1-2GB RAM 10
·        server with 2-4GB RAM 20
·        server with 4+ GB RAM 25
The recommended values for the MaxSpareServers value should be set as double that of MinSpareServers.


Comments

Popular Posts

Install and configure rsyslog Centralized logging server in CentOS

How to fix postfix/smtp Network is unreachable error

Could not join realm: Necessary packages are not installed: sssd-tools sssd libnss-sss libpam-sss adcli