The usage of .htaccess files is totally overrated these days, it is often used for things it’s orginally not intended for, like complex RewriteCond and RewriteRule sets.
In this article I will show you how not to use a .htaccess, with some benchmarking and what will happen to a strong webserver when it has to process a large .htaccess file.

Read the whole story. or go straight to Part 2 – The Solution
Even if it’s not your server, you should care about performance.
If .htaccess is enabled the Apache will look on every access to every path if a .htaccess is existing.
If not it will proceed loading the requested file, otherwise it’s parsing and processing the .htaccess file.
Depending on the filesize of .htaccess, large files are much the worse, your Apache has to ‘cache’ the file for the access.
If you are using a ‘static’ set of RewriteRules and having access to the Apache configuration, then take the pain off your Apache and add the rules to your Apache configuration.
Otherwise, try to avoid using complex and themself repeating rulesets in your .htaccess files.
![]()
A 1.6 MiB large .htaccess file, like this one, is a huge pain for your Apache.
Some details of this file, for the stat whores of you:
So, this means the poor Apache have to process about 12,000 Rules in nearly 200 Rulesets on every page request.
Ok, I did a benchmark with the site which is using that large .htaccess, where I got the stats above from. The webserver is an Intel Xeon 3050 DualCore with 2 MiB cache and 16 GB (2×8) ECC DDR2 RAM, not that bad hardware for a modern webserver.
First I tried to benchmark it with 1000 requests and 100 concurrent connections, well it quit. Then I tried 1000 requests and 10 concurrent connections, didn’t got finished too.
It worked with 30 requests and 10 concurrent connections …. and the Apache had a (short) lockdown while the test ran and I was trying to access the site myself with a webbrowser!
ab -n 30 -c 10 http://shops.example.com/example_shop
Benchmarking shops.example.com (be patient).....done
Server Software: Apache/2.2.4
Server Hostname: shops.example.com
Server Port: 80
Document Path: /example_shop
Document Length: 16285 bytes
Concurrency Level: 10
Time taken for tests: 7.17990 seconds
Complete requests: 30
Failed requests: 29
(Connect: 0, Length: 29, Exceptions: 0)
Write errors: 0
Total transferred: 502141 bytes
HTML transferred: 491011 bytes
Requests per second: 4.27 [#/sec] (mean)
Time per request: 2339.330 [ms] (mean)
Time per request: 233.933 [ms] (mean, across all concurrent requests)
Transfer rate: 69.82 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 26 27 0.6 27 28
Processing: 1621 2110 319.3 2123 2647
Waiting: 1552 2046 316.8 2063 2553
Total: 1648 2137 319.2 2151 2674
Percentage of the requests served within a certain time (ms)
50% 2151
66% 2280
75% 2379
80% 2517
90% 2613
95% 2657
98% 2674
99% 2674
100% 2674 (longest request)
The above benchmarks clearly shows that this ‘monster’ of webserver hardware could not manage a small number of requests, because the Apache is busy with parsing the .htaccess file and the rulesets inside it.
In short words, the Apache totally got fucked up.
Apache Tutorial: .htaccess files
ab – Apache HTTP server benchmarking tool
ChangeLog:
Last Update: 2008/01/30 – 01:30 p.m. (CET)
Kommentare
exciting
I can’t wait to see the solution to this problem! :-)
Part 2 will follow asap
As you know housetier, I already have a solution in my mind.
Part 2 will follow as soon as possible. I promise! ;-)
Hay you have done a
Hay you have done a fabulous job especially the Time taken for tests: 7.17990 seconds is appropriate to judge the capabilities. Good work! Carry on good work. Lets talk about the IT field 132-S-712 .In the whole world the most recognized company in the IT field is the Microsoft. It brought the great revolution in the Information Technology. Due to the latest developments in the field of Information Technology, Microsoft is going to offer a large number of Microsoft exams such as 0B0-107 exam and also provide the 0B0-410 sample exam to facilitate the people. Microsoft exam whether that is 132-S-708 or any one else is the test of your skills that’s why Microsoft certifications are becoming popular all over the world as the most credible documents in the field of IT.
Informative blogs ever much
Informative blogs ever much 70-290 viewed, after a long time I found that type of site. I love to reading blogs because 70-291 there are many new information and updates and your article have good information 70-294 I like it thanks for sharing.i bookmarked this site and emailed it to a few friends, your post was that great, keep it up.i will come back here to see more updates in future 70-432 as well.my best wishes for you always so keep it up.regards
Kommentar hinzufügen