How to make Apache faster for Drupal
If you are reading this blog post you must be striving to improve the performance of your site. When we speak about performance two things should be taken into account essentially.
- Number of requests the site is able to serve (The more, The better)
- Response time per request (The least, The better)
I guess it is not much needed to stress as how essential the response time plays in deciding the success of a website. Apache the prominent Web server plays a key role in this connection.
When configuring Apache for Drupal most of the tutorials recommend changing AllowOverride directive to All, including the official handbook page in drupal.org https://drupal.org/node/36628 , while the default is None.
This is needed to make .htaccess file in Drupal core to override the Apache config as needed. Especially to get clean url working. Besides it let's to set page expiry time, and setting necessary headers for css/js gzip compression if supported.
But this is a performance killer change!
Reason when AllowOverride is set to All. It prompts Apache to look for the existence of .htaccess file in recursive sub-folders as below.
and goes on...
Eventually the number of I/O calls needed to serve the page request spikes up. Beware, I/O calls are expensive. And it goes further worst depending on the number of modules you have. Especially if you have hosted the site in VPS environments where disk operations are sub-optimal and can't be fully virtualized. The workaround for this problem is to tell Apache explicitly the location as where to look for overriding .htaccess file.
The following config helped us to fix the issue.
Additionally apache's module mod_expires and mod_headers could be installed as Drupal's core .htaccess tries to leverage it if they exist.