Some Performance Thoughts on ASP.NET 2.0
One of the lucky things on my Vista upgrade is IIS7, or better said the unlimited IIS. IIS 5.1 which is part of Windows XP limits the amount of sessions to 10. Now I can make performance tests with Visual Studio 2005 Test.
I have a scenario where client and server is same machine (yes i know, dont do that). I call a page which contains a gridview of customers.
First test should show how bad it is to have debug enabled.
First Test
| | | Indikator | Instanz | Kategorie | Computer | Farbe | Bereich | Min. | Max. | Durchschn. | | User Load | _Total | LoadTest:Scenario | XP-PRE4 | | 100 | 0 | 25 | 22 | | Requests/Sec | _Total | LoadTest:Request | XP-PRE4 | | 100 | 51,2 | 58,2 | 54,8 | | Avg. Response Time | _Total | LoadTest:Request | XP-PRE4 | | 1 | 0,43 | 0,48 | 0,45 | | Available MBytes | - | Memory | XP-PRE4 | | 1000 | 635 | 639 | 637 | | Exceptions | _Total | LoadTest:Errors | XP-PRE4 | | - | - | - | - | | Http Errors | _Total | LoadTest:Errors | XP-PRE4 | | - | - | - | - | |
Result with debug=false
| Requests/Sec | _Total | LoadTest:Request | XP-PRE4 | | 100 | 49,8 | 58,6 | 55,0 |
which is nearly the same, but the available RAM was a little bit more.
Datareader in SQLDatasource
| Requests/Sec | _Total | LoadTest:Request | XP-PRE4 | | 100 | 55,0 | 63,8 | 60,9 |
| Available MBytes | - | Memory | XP-PRE4 | | 1000 | 654 | 703 | 691 |
The default setting is dataset, which is needed eg for paging. The difference is 10% faster and some more memory available.
DataCaching of SQLDatasource 5 seconds
| Requests/Sec | _Total | LoadTest:Request | XP-PRE4 | | 100 | 44,2 | 78,2 | 74,5 |
Not much as i expected, but scenario is not realistic enough cause SQL Server is also on same machine.
Caching 1 second
| Requests/Sec | _Total | LoadTest:Request | XP-PRE4 | | 100 | 28,2 | 78,2 | 71,1 |
What i expected
Disable Viewstate in Page
| Requests/Sec | _Total | LoadTest:Request | XP-PRE4 | | 1000 | 97 | 101 | 99 |
Viewstate makes problems in traffic and processor use. Reducing size speeds up.
Use localized Page
| Requests/Sec | _Total | LoadTest:Request | XP-PRE4 | | 100 | 96,4 | 99,8 | 98,2 |
Something i was always afraid of, using the new features like sitemap navigation, themes or resx files. Seems nearly have no influence in performance.
Output Cache 10 seconds
| Requests/Sec | _Total | LoadTest:Request | XP-PRE4 | | 1000 | 64 | 250 | 231 |
What i know from beginning, output cache boost and winform developers doesn't have a feature like that. We have now near 4-5 time more request per second. 1 server instead of 4 !
Additonal set a label
| Requests/Sec | _Total | LoadTest:Request | XP-PRE4 | | 1000 | 41 | 103 | 95 |
This test is a preparation for my next step. I added a label which is set in the Page Load with the current time. No Output Caching.
Substitution Control
| Requests/Sec | _Total | LoadTest:Request | XP-PRE4 | | 1000 | 249 | 263 | 256 |
Now i have switched on Output Cache again with 10 seconds. I replaced the label with a substitution control and implemented the shared(static) method to replace the current time in the cached result. As you can see the result is approximately the same as 2 test before ( it is a little bit faster which make no sense).
But as i posted earlier in my blog substitution is not supported by iis 7 integrated mode. Which brings me to my next test.
Application Pool integrated, no Cache
| Requests/Sec | _Total | LoadTest:Request | XP-PRE4 | | 100 | 66,0 | 75,8 | 70,7 |
Application Pool classic (ISAPI)
| Requests/Sec | _Total | LoadTest:Request | XP-PRE4 | | 100 | 62,8 | 71,2 | 69,6 |
As you see the difference is quite small but as expected integrated is faster.
I hope this gives a idea what you can do to increase the performance of your ASP.NET application.
My tip at the bottom line: dont trust anybody if talking about performance, measure it!