Forum Moderators: phranque

Message Too Old, No Replies

Premature Optimization?

Am I unnecessarily worrying considering the load I currently get?

         

curlybill09

1:57 am on Feb 26, 2007 (gmt 0)

10+ Year Member



I have been reading everything I can about mod_rewrite, trying to learn as much as possible... but the one thing I am just unsure about is whether or not I should implement it all within my .htaccess files or by editing my httpd.conf.

If I had my druthers, I would most certainly rather keep it all in the .htaccess files because I know how to do that, it's easy and most importantly, I have no clue how to edit httpd.conf... I am not a good server admin.

However, all I am reading is that .htaccess is highly intensive on the server as it is per-directory and needs to be called (processed) with every request. I generally have 7-10 rewriterules within my .htaccess files in various sections of my website, and my website receives on average about 5,000 unique visitors per day. I do have a dedicated server with 2GB RAM.

If I went ahead and implemented mod_rewrite using .htaccess files, would I be making a big mistake if website performance is important to me? Or am I falling victim to "premature optimization"? I can understand a Fortune 500 company not wanting to use .htaccess files, but for my server, will there be any noticeable decrease in server speed?

If someone installs a blog like WordPress, or a content management system like Drupal, Joomla, etc. that has built-in or pluginable rewritten URL's... is that always done by .htaccess modifications? I'm guessing it doesn't have anything to do with httpd.conf. Correct?

Thanks for any guidance or help you can provide. Take care.

jdMorgan

3:05 am on Feb 26, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The difference is that in .htaccess, the directives are interpreted for each HTTP request, whereas in httpd.conf (or other server config-level files such as conf.d), the directives are compiled at server restart, and are then executed as native machine code for each HTTP request. The terms "interpreted" and "compiled" are used here in their formal computer-science meanings.

So there is a huge performance advantage to putting code into httpd.conf on very-busy sites.

There is also a disadvantage: As implied above, in order to update your "code" in httpd.conf, you must restart your server, so that your changed code will be re-compiled so that those changes will go into effect.

Your "sixth sense" about all this seems well-centered and reasonable: At 5000 uniques per day, and with so few rules, there's nothing to worry about as long as your code is tight and well-written.

Jim