ASP.NET MVC 3剃须刀的性能 [英] ASP.NET MVC 3 Razor performance
问题描述
重要更新:见底部更新5没有在asp.net MVC 3没有性能问题,这是一个基准的问题
我做了在asp.net mvc2,3 ASPX和3剃须刀一个简单的Hello World项目和基准他们。我看到的是:
每秒系统请求
-------------------------------------------
asp.net MVC 2 ASPX 4200
asp.net MVC 3 Beta 1的ASPX 3200
asp.net MVC 3 Beta 1的剃须刀1700
这有什么错剃须刀,它这么慢?
更新:
我重做测试。所有4个测试虚拟目录使用相同的.NET 4集成模式的应用程序池。所有项目都与增加新的空X项目并添加1页1行文字,并没有code完成。所有网站都汇集在释放模式。我的系统是Windows 7中,4 GB的i7四核。我已经运行测试2次热身IIS,这些都是第二轮的结果。阿帕奇板凳参数:AB -n100000 -c1000
结果:
每秒钟CPU利用系统的要求
-------------------------------------------------- -
asp.net 4 4780 43%
MCV 2 4322 58%
MVC 3测试版1 ASPX 2324 54%
MVC 3 Beta 1的剃刀1615 54%
更新2 斯科特Guthrie的回答在他的博客:
的我们还没有完全优化MVC3但(通常有很多缓存优化,我们做的)。我们预计剃刀是相同的性能在.aspx视图发动机它最后释放。的
块引用>每秒钟CPU利用系统的要求
-------------------------------------------------- -
MVC 3 RC1剃刀1960年54%
MVC 3 RC2剃须刀2187 54%
MVC 3 RC2的aspx 4014 58%更新5 在发布模式,但问题是
调试=在我的web.config文件中真实
(即也做了所有测试影响发行版本)时,它后更改为固定假的,问题。而且它们也同样吸引它是如何在这个规模只影响剃刀模板。这应该是我们心中的部署。每秒钟CPU利用系统的要求
-------------------------------------------------- -
MVC 3 RC2剃须刀3940 58%
MVC 3 RC2的aspx 4100 58%由于ASP.NET MVC团队,出色的工作!
解决方案(新的答案,你的RC2数字回应)
感谢更新的数字。有几点:
- 您的.aspx的数字好看,因为我们预计MVC3 .aspx的是在同水准与MVC2 .aspx的(有点在这样一个Hello World示例较慢,预计)
感- 您的剃须刀数字看起来嫌疑。我们知道剃刀比等效.aspx的慢一点,然而,不同的应不超过5%-7%大。您的数字表明慢50%,这根本不符合我们的研究结果相符。检查项目编译版本中,你有
调试=false的
在web.config中设置。- 您的CPU使用率是有点怀疑。随着1000的并发请求的CPU应该点移动平均滤波器100%。 (即使只有8个并发请求应该足够,因为你有8个虚拟内核)
- 您的测试运行了大约20-25秒。这是偏低一点,因为其他系统中的活动的短(1-2秒)的突发可以甩开你的结果相当显著。
- 相关点4,你有没有运行每个场景一次或几次?你看到的结果产生多大差异?由于你的操作系统是在后台做其他事情很典型地看到运行之间的不同的结果。
Important Update: See update 5 at the bottom there is no performance issue in asp.net mvc 3, this is a benchmark issue
I've made a simple hello world project in asp.net mvc2,3 aspx and 3 razor and benchmarked them. What I see is:
System Requests per second ------------------------------------------- asp.net mvc 2 ASPX 4200 asp.net mvc 3 Beta 1 ASPX 3200 asp.net mvc 3 Beta 1 Razor 1700
What's wrong with razor, it's so slow?
Update: I've redone the test. All 4 test virtual directories uses the same .net 4 integrated mode app pool. All projects are done with add new empty x project and adding 1 page with 1 line text and with no code. all sites are compiled in release mode. My system is windows 7, 4 gb i7 4 cores. I've run the test 2 times to warm up iis and these are second run results. apache bench parameters : ab -n100000 -c1000 results:
System Requests per second CPU Utilization ---------------------------------------------------- asp.net 4 4780 43% mcv 2 4322 58% mvc 3 beta 1 aspx 2324 54% mvc 3 beta 1 razor 1615 54%
Update 2 Scott Guthrie answered in his blog:
We haven't fully optimized MVC3 yet (there is usually a lot of cache tuning we do). We expect razor to be the same performance as the .aspx view engine before it is finally released.
System Requests per second CPU Utilization ---------------------------------------------------- mvc 3 rc1 razor 1960 54% mvc 3 rc2 razor 2187 54% mvc 3 rc2 aspx 4014 58%
Update 5 all tests done in release mode but, the problem was
debug="true"
in my web.config file (that also effects release builds), after change it to false, issue fixed. And it's interesting how it's effecting only razor templating at this scale. This should be in our mind on deployments.System Requests per second CPU Utilization ---------------------------------------------------- mvc 3 rc2 razor 3940 58% mvc 3 rc2 aspx 4100 58%
Thanks to asp.net mvc team, excellent job!
解决方案(new answer to respond to your RC2 numbers)
Thanks for the updated numbers. A few points:
- Your Aspx numbers look good, in the sense that we expect MVC3 Aspx to be on par with MVC2 Aspx (a bit slower in such a Hello World example is expected)
- Your Razor numbers look suspect. We know Razor is a bit slower than the equivalent Aspx, however, the difference should be no larger than 5%-7%. Your numbers indicate 50% slower, which simply does not match up with our results. Check if the project compiles in Release and you have
debug="false"
set in web.config.- Your CPU utilization is a bit suspect. With 1000 concurrent requests the CPU should be utlized 100%. (Even only 8 concurrent requests should be enough since you have 8 virtual cores)
- Your tests are running for about 20-25 seconds. That's a bit on the low side because a short (1-2 seconds) burst of activity elsewhere in the system could throw off your results quite significantly.
- Related to point 4, did you run each scenario once or a few times? Are you seeing much variance in the results? Since your OS is doing other things in the background it's typical to see different results between runs.
这篇关于ASP.NET MVC 3剃须刀的性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!