in Apache

How to optimize and speed up your server

1 Star2 Stars3 Stars4 Stars5 Stars (8 votes, average: 4.88 out of 5)

When it comes to speeding up a server, the primary choice of most people is to add more hardware resources. This will certainly improve the performance, but will cost you fair amount of money.

The fact is that you can improve the performance by tweaking the services. The basic principle is to identify the services consuming the most of the resources and change their settings to suit your server. You don’t have to be too much technical to optimise your server.

The web and database servers are the frequently used services in a server and they consume most of the resources. Apache and MySQL are the widely used web and database servers. This article focuses on altering the Apache and MySQL services to improve the performance.You need to have shell access with root privileges in the server to modify the configuration settings.

The Apache’s configuration file is located at “/usr/local/apache/conf/httpd.conf” in a cPanel server and at “/etc/httpd/conf/httpd.conf” in a Plesk server.


This directive “Timeout” is used to define the amount of time Apache will wait for a GET, POST, PUT request and ACKs on transmissions before automatically disconnect when idle time exceeds this value. The ideal value will be 120 in heavily loaded servers. It is recommended 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 on your network and server setup. The best is to experiment with different values to find the one that fit your need.


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.


This directive is used to define the number of requests allowed per connection when the KeepAlive option above is set to “On”. When the value of this option is set to “0” then unlimited requests are allowed on the server. For server performance, it’s recommended to allow unlimited requests.


This directive 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.


This directive 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. This is an important tuning parameter regarding the performance of the Apache web server. For high load operation, a value of “512” is recommended. For standard use, you can set the value to “256”.


This directive 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. The idle value is 10 MaxSpareServer: This directive 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.The idle value is 15.


This option “MaxRequestsPerChild” is used to define the number of requests that an individual child server process will handle. Set this directive to “0” to get the maximum performance and scalability for the server.


This directive if set to “Off”, specifies to disable DNS lookups. It’s recommended to set this option to “Off” in order to avoid latency to every request, to save the network traffic time, and to improve the performance of your Apache web server.

Once you have finished optimising Apache, you can proceed with the MySQL optimisation. As in the case of Apache, you will have to modify the MySQL configuration file. This file is located at “/etc/my.cnf” in cPanel and Plesk servers. You will have to reboot the MySQL server (/etc/init.d/mysqld restart) after making any changes to the configuration file.

A lot of MySQL tuning scripts are available today. You can use one of those scripts here . It is a perl script and you can run it using the command “perl”. This will list the changes that you will have to make to the configuration file.

# wget
# perl

The output of the script will be like:

Variables to adjust:
query_cache_size (>= 8M)
join_buffer_size (> 128.0K, or always use indexes with joins)

thread_cache_size (start at 4)
table_cache (> 64)
innodb_buffer_pool_size (>= 33M)

So you need to set the query_cache_size to 8MB or more. You can add the directive “query_cache_size=8M” in the MySQL configuration file to accomplish this. Similarly make changes to other directives, restart MySQL service and run the tuning script again.

Optimising a server is not just confined to tweaking Apache and MySQL. You can tweak other services, switch to alternate webservers like Litespeed , schedule tasks with high resource usage like backups to off peak hours etc to improve the performance.

Related Posts

Written By:

Blog for everything about hosting, website, server and technical support

Add a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.