the most awesome guy ever.

Darryl E. Clarke

  Games, Linux, Mac, Websites, and More

A Pinch of Performance (Apache Tuning)

If you’re using rewrite rules and other special configuration directives on your website, like any Zend Framework site does, you might want to consider the following:

Avoiding .htaccess and ‘AllowOverride [not none]’ on large websites.

You see, when a person comes along to your site


http://myawesomesite.com/some/random/page/in/the/depths/of/hell

Apache, if told to AllowOverride will start looking for .htaccess files. The above URL translates to apache as:


./document_root/some/random/page/in/the/depths/of/hell

And as such, Apache needs to find out if you have any .htaccess files configured. It will search in this order:


./document_root/some/random/page/in/the/depths/of/hell/.htaccess
./document_root/some/random/page/in/the/depths/of/.htaccess
./document_root/some/random/page/in/the/depths/.htaccess
./document_root/some/random/page/in/the/.htaccess
./document_root/some/random/page/in/.htaccess
./document_root/some/random/page/.htaccess
./document_root/some/random/.htaccess
./document_root/some/.htaccess
./document_root/.htaccess (oh, hey! I found one!)

After it finds one, it processes it and then decides what to do. “Oh, you’re using a framework? I’d best do as I’m told.” On the other hand, if you’ve avoided AllowOverride and have it set to ‘none’, Apache will not search for .htaccess files. If you’ve got it set to None and you need rules, these rules can easily be placed inside your virtual host configuration. This way when Apache gets the request it already knows you’re using a framework and doesn’t waste time searching for files that may not exist.

The overall benefit to this? It may only be a few milliseconds in the long run. But hey, it’s worth it when your site explodes into mass popularity for an hour. That’s thousands of seconds saved!

Tags: , , , ,