本文介绍了ASP.NET MVC 3剃须刀的性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

重要更新:见底部更新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的回答在他的博客:

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:

  1. 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)
  2. 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.
  3. 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)
  4. 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.
  5. 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剃须刀的性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-30 21:25