Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/performance/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Performance .htaccess mod_重写性能_Performance_.htaccess_Mod Rewrite - Fatal编程技术网

Performance .htaccess mod_重写性能

Performance .htaccess mod_重写性能,performance,.htaccess,mod-rewrite,Performance,.htaccess,Mod Rewrite,我在SOF上搜索了很多关于.htaccess和mod_rewrite的内容,我想从性能角度看哪一个更快: RewriteRule ^([a-z0-9]+)/?$ index.php?id=$1 [NC,L] RewriteRule ^(.*)/?$ index.php?id=$1 [NC,L] RewriteRule ^([^/]*)/?$ index.php?id=$1 [NC,L] 因为第一个只接受字母和数字,所以执行起来更快吗 如果有疑问,请进行测试。我用Apache2安装了一个运行Ub

我在SOF上搜索了很多关于.htaccess和mod_rewrite的内容,我想从性能角度看哪一个更快:

RewriteRule ^([a-z0-9]+)/?$ index.php?id=$1 [NC,L]
RewriteRule ^(.*)/?$ index.php?id=$1 [NC,L]
RewriteRule ^([^/]*)/?$ index.php?id=$1 [NC,L]

因为第一个只接受字母和数字,所以执行起来更快吗

如果有疑问,请进行测试。我用Apache2安装了一个运行Ubuntu2011.10的测试服务器,并使用Sakege负载测试应用程序执行了3个测试。测试运行了1分钟(或直到5000次失败),有50个并发用户请求“/index.html”

测试#1使用了以下重写规则配置:

RewriteEngine on
RewriteRule ^([a-z0-9]+)/?$ /index.html?id=$1 [NC,L]
RewriteEngine on
RewriteRule ^(.*)/?$ /index.html?id=$1 [NC,L]
围攻的结果是:

Transactions:                 300970 hits
Availability:                  98.36 %
Elapsed time:                  57.25 secs
Data transferred:              20.38 MB
Response time:                  0.00 secs
Transaction rate:            5257.12 trans/sec
Throughput:                     0.36 MB/sec
Concurrency:                    9.04
Successful transactions:      300970
Failed transactions:            5009
Longest transaction:            0.02
Shortest transaction:           0.00
使用重写规则配置测试#2:

RewriteEngine on
RewriteRule ^([a-z0-9]+)/?$ /index.html?id=$1 [NC,L]
RewriteEngine on
RewriteRule ^(.*)/?$ /index.html?id=$1 [NC,L]
结果是:

Transactions:                 225244 hits
Availability:                  97.82 %
Elapsed time:                  42.43 secs
Data transferred:              15.25 MB
Response time:                  0.00 secs
Transaction rate:            5308.60 trans/sec
Throughput:                     0.36 MB/sec
Concurrency:                    8.71
Successful transactions:      225244
Failed transactions:            5009
Longest transaction:            0.18
Shortest transaction:           0.00
Transactions:                 210469 hits
Availability:                  97.68 %
Elapsed time:                  39.39 secs
Data transferred:              14.25 MB
Response time:                  0.00 secs
Transaction rate:            5343.21 trans/sec
Throughput:                     0.36 MB/sec
Concurrency:                    8.60
Successful transactions:      210469
Failed transactions:            5009
Longest transaction:            0.02
Shortest transaction:           0.00
使用以下重写规则测试#3:

RewriteEngine on
RewriteRule ^([^/]*)/?$ /index.html?id=$1 [NC,L]
结果是:

Transactions:                 225244 hits
Availability:                  97.82 %
Elapsed time:                  42.43 secs
Data transferred:              15.25 MB
Response time:                  0.00 secs
Transaction rate:            5308.60 trans/sec
Throughput:                     0.36 MB/sec
Concurrency:                    8.71
Successful transactions:      225244
Failed transactions:            5009
Longest transaction:            0.18
Shortest transaction:           0.00
Transactions:                 210469 hits
Availability:                  97.68 %
Elapsed time:                  39.39 secs
Data transferred:              14.25 MB
Response time:                  0.00 secs
Transaction rate:            5343.21 trans/sec
Throughput:                     0.36 MB/sec
Concurrency:                    8.60
Successful transactions:      210469
Failed transactions:            5009
Longest transaction:            0.02
Shortest transaction:           0.00

抱歉,但IMHO Jason的回答表明他不理解基准测试的一些基本原理。传播速度非常明显,[a-z0-9]比其他两个(非常接近)快,分别为225244和5308t/s,点击次数为300000次和5272t/s。很不错的!谢谢你,但是你的整个方法是-1。查看我的对位回答。+1,尽管我不确定
IMHO
中的
H
代表什么。也许你可以解释一下“谦逊”但我在一篇帖子后被某人狠狠地骂了一顿--“你听起来一点也不谦逊”,所以我现在倾向于坚持IMO;-?