Top tips to Tune Apache
Top tips to tune apache
Apache is the the web server that dominantly runs highest part of web application hosted on the internet. Here are some tips which helps to keep the server updated and ensures highest possible performance is delivered.
1.Vanish out the unused modules :
The modules are designed to provide certain functionalities. Any VPS server can be involved with a number of such modules. The modules which currently is not required and is not assigned with any of the functionalities also consumes the memory and adds its part to the load.so removing such modules can help you reduce the load.
Include but not limited to mod_php, mod_ruby, mod_perl etc
2.Allocate RAM wisely
RAM is the major component to be taken into consideration while you are thinking to performance tune your apache. The RAM allocated each of the apache process is the major thing to be taken into consideration. You can not do it directly , but the same can be achieved by number of child processes through the MaxRequestWorkers, doing this will limit the RAM usage by apache. You can always alter these values as per your requirement.
You can do it by considering the average amount of RAM used by Apache then multiply it by number of MaxRequestWorkers, and you will end with the amount of memory that will be allocated for apache processes.
3.Consider upgrading the server if you are using kernel older than 2.4
The kernel version 2.4 and above are provided with the send file kernel system call, enabled by default. That enables high performance to deliver of network files, This makes possible for Apache to deliver static files even faster. And with low CPU utilization by performing simultaneous read and send operations. Some of the old customers who have bought the dedicated server from us, have already upgraded to avoid this problem.
Kernel version > 2.4
4.Configure mod_disk_cache with the hierarchy :
The cache cleaning activity also has the impact on the performance of apache. Configure the apache in such a way that CacheDirLevels to be prioritized as 1, against CacheDirLength as 2. This ensures that the htcacheclean will not take forever while cleaning up your cache directory.
CacheDir Length =2
5.Put cache on separate physical disks.
Put the cache on separate disk. This makes accessing of the cache faster without interrupting the other processes.
6.Compress and Transmit
While sending the files compress the files and send it. This reduces the size of the file and it always offers the best experience for the user. The user at another end can simply unzip the file and use.
7.Turn off the DNS lookup
You should avoid doing the DNS lookups, you rarely require them and when you do, you can look them up after the fact.
8.Put the log file to the different disks.
You should put all the log files into other physical disks rather than putting into the disk that is serving.
Make Allowoverride None. This will prevent apache from having the check for a .htaccess on each request.
There are two ways to disable the .htaccess
By apache configuration : you can set AllowOverride to none in the apache configuration that will completely disable the .htaccess
AllowOverride -> None
Deleting the .htaccess file. By doing these also the htaccess can be restricted but it is not recommended to do.
10.Always use the latest version of Apache
The updates are always intended to deliver the best possible performance. Having the latest version can help you get rid of the present bugs. This could add the level of convenience to the user.
11.Use the multi processing module that works best for your case.
Commonly the MPM extends to the modular functionality of apache by letting you to decide how to configure the web server to bind the network ports on the machine and other factors like how to accept request from the clients and user children processes to handle such request.
12.Do not configure keep alive timeout too high
The keep alive timeout should be configured with the low values unless it keeps the door open to consume more resources on the server.
13. Use mod_disk_cache not mod_mem_cache
The mod_mem_cache will not share its cache among the other running apache processes. This will cause high memory usage with little performance gain.
14. Setup appropriate expires, E-tag and cache-control headers
The perfect utilisation of the cache will impact on the performance of the apache. To utilise it perfectly you must tell when it has to expire with the tags attached notified in them. Else it will simply remain as the part of the cache and you won’t be able to make use of the cache properly.
15. prefer piped logging instead of direct logging
When you want to rotate the log file and you opt for direct logging into that file it will face certain issues.for this you need to restart your apache server. This will reflect as the significant slowness in the server.
16.Avoid using the hostname in the configs
You must keep the hostname lookups off. This will avoid you for waiting for the DNS server to look for your hostname you can use ip addresses instead.
17. Use the persistent connections
Set keep alive instances on, and then set the values for keep alive timeout and keep alive requests.
The keep alive timeout is the time defined for what amount of time the apache should wait for the next requests to come in.
Keepalive_requests is the one which defines maximum number of requests allowed.
18. Increase swappiness
This factor will make the cache to access more number of files for the faster execution.
In the Linux system /proc/sys/vm/swappiness to 60 or greater.
19.Increase your write buffer
Increase the write buffer size for tcp/ip buffers. Increase proc/sys/net/core/ wmem_max and /proc/sys/net/core/wmem_default . If your pages fit in within this server, the apache will compelte the one call to the tcp ip buffer
20. wash out the buffers early for the render
It takes relatively more time for the pages to create it from the backend. Flush your buffer to send the partial page to the client. This can be done effectively at the head of the page.
21.use cache for the frequently used data
Using the cache for the frequently used data and the sessions.IT will speed up your apache render time as the databases are slow.
Allow content negotiation for the faster response.
23. Tune your Mysql settings for better performance
There is a free script available mysqltuner.pl you can run this script within apache. Ti helps you to detect the bottleneck within the database. When you run this script within the terminal you will get to know how you can fix them.
24.Use a PHP accelerator
When you are using PHP for your website you must install the PHP caching /accelerating application. These types of accelerators helps to push the data whenever there is a request for it.
25.Reduce the number of processes.
The processes consumes more of the memory and acts as a barrier to the performance of the apache. Reducing the number of processes can help you solve this immediately.
HostingRaja are into providing the various hosting services and domain related services at most affordable prices. The world class technology used within the server ensure the highest quality performance is delivered. To know more about the plans and features offered navigate to hostingraja.in