How to improve your Apache Web server’s performance?
November 20, 2012
The performance of web application depends upon the performance of the web server and the database server. You can increase your web server’s performance either by adding additional hardware resources such as RAM, faster CPU etc. or you can get better performance on the same hardware through Cloud Management, by doing some custom configuration to the web server.
Here are some custom configurations for better performances
- Load only the required modules:
Apache server is a modular program which includes the functionality of selecting a set of modules. So it’s suggested to run Apache with only the required modules which will reduce the memory footprint and hence the server performance.
- Choose appropriate MPM:
Apache comes with a number of Multi-Processing Modules (MPMs) which binds the network ports to the machine. But only one MPM can be loaded at a time, so choose the appropriate MPM for your application. It depends on various factors like, whether the OS supports threads, available memory, scalability versus stability, whether non-thread-safe third-party modules are used, etc.
- DNS lookup:
Keep “HostnameLookups off” to reduce latency to every request since the DNS lookup has to be completed before the request is finished.
Make “AllowOverride all” to reduce additional file system lookups.
Add the option ‘FollowSymLinks’ to make the server follow the symbolic links in the directory.
- Content Negotiation:
Option ‘Multiviews’ scans the directory for files, which causes latency.
‘MaxClients’ is the limit on maximum simultaneous requests. It should be set to low so that new connections are put in queue.
- MinSpareServers, MaxSpareServers, and StartServers:
The ‘MinSpareServers’ and ‘MaxSpareServers’ determines how many child processes should be kept waiting for request. Now you can adjust it as your requirement.
Listed below are some tweaks to help you around
- KeepAlive and KeepAliveTimeout:
The ‘KeepAlive’ directive allows multiple requests to be sent over the same TCP connection. This is useful when HTML pages use a lot of images.
- HTTP Compression & Caching:
Use mod_deflate module for HTTP Compression. Most of the browsers are supporting it.
- Separate server for static and dynamic content:
For dynamic contents Apache server needs 3M to 20M of RAM, while for the static contents it consumes only 1M. To reduce latency use separate servers for static and dynamic contents.
- Reducing network load:
Use ‘mod_gzip’ to compress the data in order to reduce bandwidth. Most of the browsers are supporting it.