Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How much does using htaccess files slow down website performance (especially with solid state disks)?

Tags:

The Apache docs say (http://httpd.apache.org/docs/2.4/howto/htaccess.html),

"You should avoid using .htaccess files completely if you have access to httpd main server config file. Using .htaccess files slows down your Apache http server. Any directive that you can include in a .htaccess file is better set in a Directory block, as it will have the same effect with better performance."

But that gives me no idea of the scale of the impact.

I have an architecture designed for shared hosting where the only choice was to use htaccess files.

I'm moving over to Digital Ocean where I can do what I like.

I need to make a judgement on whether to stick with htaccess files or move stuff from there into the centralized config files and switch them off.

There could be 100s of small low-use sites (local businesses).

If the performance hit amounts to under about 50ms in serving a page or has some other minor hit like reducing the number of concurrent accesses that can be supported by under about 5%, then I don't care.

If the effect is big enough that people might feel the difference, then I care enough to spend time changing things.

But I've found nothing that gives me an indication of what order of magnitude of the hit I can expect.

Can anyone enlighten me?

Edit: I'm not looking for anything like exact numbers. But surely someone somewhere who is more able than me has done some benchmarking, or knows from experience the type of difference there can be under particular circumstances.

like image 619
Nick Rice Avatar asked Jul 31 '14 15:07

Nick Rice


People also ask

Does htaccess slow site down?

htaccess files slows down your Apache http server. Any directive that you can include in a . htaccess file is better set in a Directory block, as it will have the same effect with better performance."

Does a website need a htaccess file?

htaccess is not required for having a general website. That file simply allows you to make changes in the way your website behaves for example banning people from accessing your site or redirecting an old dead link to a new page. Some software like Wordpress requires settings in the . htaccess file (or httpd.

What is .htaccess file and why it is used?

. htaccess files (or "distributed configuration files") provide a way to make configuration changes on a per-directory basis. A file, containing one or more configuration directives, is placed in a particular document directory, and the directives apply to that directory, and all subdirectories thereof.

When should I use htaccess?

The . htaccess file is commonly used when you don't have access to the main server configuration file httpd. conf or virtual host configuration, which only happens if you have purchased shared hosting. You can achieve all of the above-mentioned use cases by editing the main server configuration file(s) (e.g., httpd.


2 Answers

From an answer on Quora by Jonathan Klein, 12ms for a 1500 line .htaccess file:

Having a large .htaccess does have a cost. Ours is currently ~1500 lines and we benchmarked the time spent parsing it at around 10-12ms on a production webserver. Hardware makes a difference obviously, but you can fairly safely assume that the cost of that 3000 line .htaccess is around 25-35ms per request.

like image 151
user1133275 Avatar answered Oct 30 '22 05:10

user1133275


That slide shows the impact of htaccess files with either no htaccess file, the htaccess file in the root folder as well as in subfolders in comparison to the no htaccess baseline.

like image 37
rkoller Avatar answered Oct 30 '22 05:10

rkoller