Optimizing Apache for VPS/Dedicated Server

Apache Optimization

The efficiency with which Apache runs can greatly be improved with a few small tweaks in the Apache configuration file. Below are the major parameters that can be tweaked to improve the performance of the server.


Timeout : This directive “Timeout” is used to define the amount of time Apache will waitfor a GET, POST, PUT request and ACKs on transmissions before automatically disconnect when idle time exceeds this value. This value is set to “120” to improve performance in heavily loaded servers. It isrecommended to set this value lower if your clients have low latencies. Some time, setting this directive to a low value may pause problem, this highly depend of your network and server setup. The best is to experiment with different values to find the one that fit your need.

KeepAlive On : This directive “KeepAlive” if set to “On”, enables persistent connections on the web server. For better performance, it’s recommended to set this option to”On” and allow more than one request per connection. In the original HTTP specification, every HTTP request had to establish a separate connection to the server. To reduce the overhead of frequent connects, the keep-alive header wasdeveloped. Keep-alives tells the server to reuse the same socket connection
for multiple HTTP requests.

MaxKeepAliveRequests : This directive”MaxKeepAliveRequests”is used to define the number of requests allowed per connection when the KeepAlive option above is set to”On”. Socket connections will be terminated when the number of requests set by the
“MaxKeepAliveRequests”directive is reached. When the value of this option is set to”0″then unlimited requests are allowed on the server.Forserver performance, it’s recommended to allow unlimited requests.

KeepAliveTimeout : This directive “KeepAliveTimeout” is used to define how much time, in seconds, Apache will wait for a subsequent request before closing the connection. Once a request has been received, the timeout value specified by the “Timeout”
directive applies. The value of “10” seconds is a good average for server performance. This value should be kept low as the socket will be idle for extended periods otherwise

StartServers : This directive “StartServers” is used to define the number of child server processes that will be created by Apache on start-up. As the number of processes with Apache 2.x is dynamically controlled depending on the load,
there is usually little reason to adjust this parameter now. Normally a default value “5” is set for this parameter.

MaxClients : This directive “MaxClients” is used to define the limit on the number of child processes that will be created to serve requests. The default means that up to 512 HTTP requests can be handled concurrently. Any further connection requests
are queued. This is an important tuning parameter regarding the performance of the Apache web server. For high load operation, a value of “512” is recommended by various benchmarks on the Internet. For standard use, you can
set the value to “256”.

ServerLimit : This directive “ServerLimit” is used to define the maximum configured value for the “MaxClients” directive for the lifetime of the Apache process. It is important to note that any attempts to change this directive during a restart
will be ignored, but the “MaxClients” directive can be modified during a restart of the server. This is another important tuning parameter directly associated with the “MaxClients” directive regarding the performance of the
Apache web server. For high load operation, a value of “1024” is highly recommended by various benchmarks on the Internet. For standard use, you can set the value to “256”. This is a performance feature. Special care must be
taken when using this directive. If “ServerLimit” is set to a value much higher than necessary, extra, unused shared memory will be allocated. If both “ServerLimit” and “MaxClients” are set to values higher than the system can
handle, Apache may not start or the system may become unstable.

MinSpareServers 10 : This directive “MinSpareServers” is used to define the minimum number of idle child server processes that should be created. An idle process is one which is not handling a request. If there are fewer than “MinSpareServers” idle, then

the parent process creates new children at a maximum rate of 1 per second.

MaxSpareServers 15 : This directive “MaxSpareServers” is used to define the maximum number of idle child server processes that should be created. If there are more than “MaxSpareServers” idle child processes, then the parent process will kill off
the excess processes and these extra processes will be terminated.

MaxRequestsPerChild 9999 : This option “MaxRequestsPerChild” is used to define the number of requests that an individual child server process will handle. This value can be set to “0” to get the maximum performance and scalability for the server. This is an important tuning parameter regarding the performance of the Apache web server again.

  • VPS, Apache, Nginx, Dedicated Server
Hasznosnak találta ezt a választ? 1 A felhasználók hasznosnak találták ezt

Kapcsolódó cikkek

Optimizing MySQL for VPS/Dedicated Server

For a basic level optimization of MySQL server you can use the MySLQ tuner script that is easily...