ASP.NET MVC 3 razor performance

Important update: see update 5 below, there is no performance problem in asp.net mvc 3, this is a test problem

I made a simple hello world project in asp.net mvc2,3 aspx and 3 razors and compared them. I see:

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 a razor, is it so slow?

Update: I redid the test. All 4 test virtual directories use the same .net 4 application pool with integrated mode. All projects are carried out with the addition of a new empty x-project and the addition of 1 page with 1 string text and without code. all sites are compiled in release mode. My system is windows 7, 4 gb i7 4 cores. I tested the test 2 times to warm up iis and these are the results of the second run. Apache scanner options: 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 replied on his blog:

We have not fully optimized MVC3 (usually we often tune the cache). We expect the razor to be the same performance as the .aspx viewer 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 performed in release mode, but the problem was debug="true" in my web.config file (which also affects the release of assemblies), after changing it to false, the fix is ​​fixed. And it is interesting how this affects only the razor templating on this scale. It should be in our minds when deployed.

 System Requests per second CPU Utilization ---------------------------------------------------- mvc 3 rc2 razor 3940 58% mvc 3 rc2 aspx 4100 58% 

Thanks to the asp.net mvc team, great job!

+62
performance c # asp.net-mvc asp.net-mvc-3 razor
Sep 30 '10 at 8:28
source share
2 answers

(new answer for answering 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 (expected a bit slower in such a Hello World example)
  • Your Razor numbers look suspicious. We know that Razor is a bit slower than the Aspx equivalent, but the difference should not exceed 5-7%. Your numbers indicate 50% slower, which simply does not match our results. Check if the project compiles in Release and you have debug="false" set in web.config.
  • Using your processor is a little suspicious. With 1000 simultaneous requests, the processor must be 100% utilized. (Even 8 concurrent requests should be sufficient, since you have 8 virtual cores)
  • Your tests run for about 20-25 seconds. This is a bit on the low side, because a short (1-2 seconds) surge in activity elsewhere in the system can significantly reduce your results.
  • As for point 4, have you run each script one or more times? Do you see many differences in the results? Since your OS does other things in the background, it is typical to see different results between runs.
+25
Dec 11 '10 at 19:58
source share

How did you complete the benchmark? Has your site been deployed to IIS in Release mode? Did you use the <deployment retail="true" /> section in machine.config? Also remember that ASP.NET MVC 3 is still under heavy development, so you cannot expect it to be fully optimized. At least wait until it reaches RTM.

+19
Sep 30 '10 at 8:37
source share



All Articles