Asp.net Web form and asp.net MVC can be compared at one time. Do not always think that asp.net mvc is better than asp.net web form.-web form pages can also be small.

Source: Internet
Author: User

After writing "don't always think asp.net mvc is better than asp.net web form -- web form pages can also be small", I received a lot of comments. Most people do not approve of my proposed practice of putting viewstate into the session. Let's test it. Build a performance testing and comparison platform. Make an application and implement it with asp.net web form and asp.net MVC respectively. The page appearances of the two applications are the same. Then build distributed servers and reverse proxies. Add an http load for performance testing to generate the server.

 

Performance testing environment

 

For example:

The performance test server generates a large number of http requests to target reverse proxy servers. The reverse proxy server directs these requests to the server using the Round Robin algorithm. The server in the response returns an http Response to the reverse proxy server, which then responds to the performance test server.

Server1 and Server2 configurations: 2 gb ram, 1 2 GHz CPU, 300 GB hard drive Windows Server 2008 R2

Configuration of reverse proxy server: 1 gb ram, 1 2 GHz CPU, 80 GB hard disk Ubuntu Linux 11.04,

Performance testing server configuration: 1 gb ram, 1 2 GHz CPU, 80 GB hard disk Windows XP

Database Server Configuration: 4 gb ram, 1 2G Hz CPU, 2008G hard drive Windows Server R2

As you can see, they are all common machines.

Squid 3.1.4, software used by reverse proxy

Server1 and Server2 deploy the same application, that is, both the application of asp.net web form and the application of asp.net MVC are deployed on these two servers. At the same time, Server1 and Server2 access the same database. Some web farm configurations are made in the application. The session is stored in the ASPState database of SQL server. Session data can be floating on different servers. Http requests can be responded by either Server1 or server2. Of course, only two IIS servers are used here. You can add more. However, the conditions are limited. Only two instances can be found. This is the smallest distributed scenario. If there are more, the overall performance of the entire system will be better. The networks here are all local networks.

Here we will talk about how to compare. Here we use the asp.net web form and asp.net MVC versions of the same application for comparison. We can see from the above that the hardware is the same. Software, divided into common three layers, BLL, DAL, are the same. The only difference is the presentation layer technology. One uses asp.net web form and the other uses asp.net MVC. The other links are the same, except that the presentation layer technology is different. This presentation layer technology is compared. In asp.net web form, viewstate is put into session. The purpose of this operation is to reduce the size of the HTML page of the web form, at the same time, viewstate and session are the same as those for floating between different servers.

Here is the download of the Code: (the oldest ado.net is used, and the TransactionScope is not used. I think for myself. I didn't use aop, so I had to repeat a lot of code. The code generated by the code generator didn't bother, and it wasn't too far away. I really want to say I can write another article ).

 

Performance Testing

 

The following describes the performance test. The loadrunner 8.1 is used. Record the script first, and then debug the script. This is all basic skills. Prepare the script. One is used to test asp.net web form, and the other is used to test asp.net MVC. Then, these scripts are bombarded with the reverse proxy server. At the beginning, it was tentative. There were only 10 users. There was no problem. If you did the test, there was no problem. If you did the test, then we continued the cycle until the pressure reached a certain level, when a failed case is returned in this performance test, it is stopped. Using this method, I tried a lot and found the data:

When the asp.net web form user is 600:

 

 

When the number of asp.net web forms users is 800:

 

When the number of asp.net web forms users is 1200:

 

When the number of users of the asp.net web form is 1500, the following error occurs:

 

When the number of asp.net MVC users is 600, there is a failure case:

When the number of asp.net mvc users is 800, the failure case is a little more:

 

 

When the number of asp.net mvc users is 1200, there are more failed cases:

 

When the number of asp.net mvc users is 1500, there are more failed cases:

 

Download complete test results: download includes the loadrunner report and loadrunner screenshot.

 

Conclusion

After comparison. The performance of asp.net web form and viewstate is not lost to asp.net MVC. It is also slightly better. As mentioned earlier, viewstate and session can be reasonably used as long as viewstate or session is not used excessively (how to make proper use, for more information, see architecture of large-scale asp.net application systems-how to achieve high performance and high scalability.) asp.net web form can also provide better performance, or even surpass asp.net MVC. Therefore, do not draw conclusions easily or simply deny a technology. Of course, there may be some limitations here, but what we see is one-sided. I hope you will have some insights.

 

 

Add content

According to the comments below, a performance test is conducted when the web form is not optimized. The so-called optimization is to put viewstate into the session. See the BasePage class in the web form project. If the backend classes of all aspx inherit the System. Web. UI. Page class, this so-called optimization is removed. After tests, we found that even if no optimization is available, the web form still has better performance than asp.net mvc. A failure occurs only when the number of users reaches 1400.

 

We can see that the viewstate is not added to the session feature, the maximum user is 1400, And the viewstate is added to the session feature. The maximum user is 1500. After the viewstate is put into the session, performance improvements seem to be limited.

Of course there are also comments and suggestions to be optimized before comparison. You can try again later. This is now the case today. Thank you.

End of 20120710 add content

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.