0

 I usually use the server config file for settings that I would like to apply to my applications (at least in the development environment), and constantly have to re-start the server.
  I know that I cannot keep re-starting the server every time during production; my choice would have to be .htaccess files.
 My question is this: how much performance issue does using htaccess files cause? I understand that it depends on how many folders the request has to traverse to obtain the required file; so here's an example:
 If the request path is host/folder1/folder2/folder3/folder4/folder5/file_requested, and the htaccess is placed in the root folder, are we talking about a significantly, measurable performance issue, or something that can be ignored? I wouldn't want to restart the server every time I need changes to an application's configuration.
Thanks.

3
  • How often you reboot? What type of URLs you have? Commented Oct 8, 2011 at 19:05
  • Because I'm constantly trying out new features on each application I put on the server, a minimum of 4 times daily (although it's mostly on the development server; yet, I usually reboot about once a day once I apply the new settings. And I don't understand what you meant by type of URL)
    – user705339
    Commented Oct 8, 2011 at 19:25
  • 1
    what I am saying is do you have rewrite rules? like /about/ => /index.php?page=about. Does your update are for development purpose? my point is here you can use .htaccess at the beginning and then move them to the vhost once it's completed. Commented Oct 8, 2011 at 19:41

1 Answer 1

1

Well, as mentioned by @Book of Zeus, this depends on how affecting are your rules.

.htaccess works with a hunting process, this means... suppose you have a file being accessed at

/var/www/foo/bar/baz/dir1/dir2/file.ext

Apache will first parse and identify if file or directory exists. Then it will check if there is any .htaccess file inside /var/www/foo/bar/baz/dir1/dir2/. If it matches, it processes and we are fine, if not, it will check the parent directory (/var/www/foo/bar/baz/dir1/) for a .htaccess and, if it encounters one, process the matching rules. If not, it proceeds to the parent and check... you got the pattern... until reach the root folder.

Summarizing, the closer to the target file the .htaccess is, higher the precedence in the hunting process.

In any case, my final suggestion is test it. Make some changes in the Apache configuration file, restart, and benchark it. Then rollback your changes a put them into a .htaccess files and run the same test. Check for response times and memory usage. Try to replicate your production load. This ca be your final silver bullet deciding which method you should adopt.

If this indicates you that changing Apache config and restart is really better, try to implement changes of the day all at once, in a nightly job run to minimize the prod impact.

PS: Apache comes with a program named "ab" - apache bench - in its default installation. You can use it to make your tests.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.