ToolKit
LANGUAGES: All .NETLanguages
TECHNOLOGIES: Application Center Test
Stress-Test Your Web Apps
Make sure your Web apps can hold up under pressure withthe Microsoft Application Center Test.
By Ken McNamee
If you've ever used Microsoft's free Web ApplicationStress tool (WAS) or Mercury Interactive's nowhere-close-to-free LoadRunnertool, you will definitely appreciate Application Center Test (ACT), includedwithin Visual Studio .NET Enterprise Architect and Enterprise Developereditions. ACT's purpose is to stress-test your Web application by flooding itwith HTTP requests defined in a script you either can record or create fromscratch. Although the other two tools I mentioned work in a similar manner, theWAS tool has some significant functionality drawbacks, and LoadRunner -although a good product - can take a significant bite out of your budget.
The importance of stress-testing your Web application codeshould be noted. It is not enough for me to tell you of a tool's existence anddescribe how to use it; I also need to convince you why you would want to useit and under what circumstances. In the case of ACT, you should use it if theperformance of your Web application is remotely important to you, either now orin the future. You might ask, "How should I know whether the performance of theapplication will be important in the future?" The simple answer to thatquestion is you probably won't know. In my experience, however, every time Ihave thought performance would never be an issue with a function or a page, ithas come back to burn me. To be safe, you should always stress-test your code.
Drawing from their experience developing the WAS tool(originally code-named, and sometimes still referred to, as "Homer"), Microsoftdevelopers succeeded in creating a much improved product. Here's a short listof some of ACT's improvements:
- It's significantly easier to create and use testingscenarios.
- It now can include dynamically generated Requestvariables.
- It lets you use VBScript to define the test'sparameters and execution flow.
- The object model is accessible via any COM client, or.NET client via COM Interop.
- It's integrated tightly with Visual Studio .NET.
- It can generate and save a large amount of testinformation.
- It creates graphs of the test results automatically.
- It supports HTTP requests using the SSL protocol(although not when using the browser recording feature).
Creating a stress-testing scenario in ACT can be as simpleor as complicated as you are willing or compelled to make it. On the simpleside, you can click on New Test and record an Internet Explorer session wherebyyou step through the pages that need to be tested. ACT records all theinformation - including any ViewState information - for each page request intoa VBScript file you can then modify to meet your needs. This is where it canget complicated because ACT has an object model you can program against. Figure1 provides an example of the auto-generated code ACT produces for only onerequest.
Sub SendRequest1()
Dim oConnection,oRequest, oResponse, oHeaders
Dim strStatusCode
If fEnableDelays = Truethen Test.Sleep (0)
Set oConnection =
Test.CreateConnection("localhost", 80, false)
If (oConnection isNothing) Then
Test.Trace"Error: Unable to create connection to " +
"localhost"
Else
Set oRequest =Test.CreateRequest
oRequest.Path ="/Default.aspx"
oRequest.Verb ="GET"
oRequest.HTTPVersion ="HTTP/1.0"
set oHeaders =oRequest.Headers
oHeaders.RemoveAll
oHeaders.Add"Accept", "image/gif, image/x-xbitmap,
image/jpeg,image/pjpeg, application/vnd.ms-excel,
application/vnd.ms-powerpoint, application/msword,
application/x-gsarcade-launch, */*"
oHeaders.Add"User-Agent", "Mozilla/4.0 (compatible;
MSIE 6.0;Windows NT 5.1; .NET CLR 1.0.3705)"
'oHeaders.Add"Host", "localhost"
oHeaders.Add"Host", "(automatic)"
oHeaders.Add"Cookie", "(automatic)"
Set oResponse =oConnection.Send(oRequest)
If (oResponse is Nothing)Then
Test.Trace"Error: Failed to receive response for " +
"URL to" + "/Default.aspx"
Else
strStatusCode =oResponse.ResultCode
End If
oConnection.Close
End If
End Sub
Figure 1. Application Center Test (ACT) has aprogrammable object model that uses VBScript by default - and optionallyJScript - to record an Internet Explorer browser session.
In addition to using the Application Center Test IDE, youcan create and run a test directly from within Visual Studio .NET. Simplycreate a new ACT Project and either record an IE session or create the testscript yourself using VBScript or JScript. Some of ACT's capabilities, however,are not available within VS .NET. One example is the dynamic test in which ACTmonitors how the Web server is responding and modifies both the order ofrequests and the request headers being sent to suit the scenario.
Once the request information has been finalized, you willneed to edit the properties of the test. Here is a list of some properties youcan change:
- Test duration, including warm-up time to give yourapplication a chance to compile and cache pages
- Whether to use randomly generated users or userinformation you have predefined
- Any performance counters you would like to track
- The number of concurrent browser connections you wouldlike to simulate
View the Results
Once you've created the test, it's time to run it. ACTcreates a thread for each browser client it is simulating and starts floodingthe Web server with requests following the script you have defined. You canwatch the test in progress as ACT displays a graph showing the number ofrequests per second and also the number of HTTP, socket, and DNS errors persecond. You should see something similar to Figure 2.
Figure 2. While the test is running, ACT displays the test's progress inboth requests and errors per second.
Once the test is completed, you are presented with theresults screens (see Figure 3). There are too many performance metrics todetail here, but it is important to note that the resolution is at the Requestlevel. Thus, ACT can tell you that a particular page performed badly but itcan't tell you which method present within the page is the culprit. That'swhere ASP.NET's tracing ability can really come in handy.
Figure 3. ACT stores a wide array of performance metrics that shouldhelp you pinpoint problem areas.
If the page is a candidate for output caching, you shouldtry to run the test with the Output Caching option first turned off and thenagain with it turned on. The results usually are pretty amazing. You can usethe same technique, however, for any type of change you make to the page.Testing before and after changes can give you a good idea of whether your codeis getting bloated or more efficient as development progresses.
Used in conjunction with ASP.NET's tracing and debuggingcapabilities, Application Center Test can help you pinpoint any performanceproblems in your Web application code. In addition, it also can help you withcapacity planning as you try to decide how many Web servers you will need tosupport the anticipated traffic. Using ACT heavily during - as well as after -development can give you an idea of how the architectural design is panning outand whether an increase in data and/or HTML caching is necessary to reach yourperformance goals. This type of information can be absolutely invaluable to theoverall success of a Web project.
Ken McNamee is a senior software engineer withRelayHealth Corp., the premier provider of secure, Web-based doctor-patientcommunication services. Prior to this, he led a team of developers inre-architecting the Home Shopping Network's e-commerce site, HSN.com, to 100percent ASP.NET with C#. E-mail him at mailto:kenmcnamee@hotmail.com.
Tell us what you think! Please send any comments aboutthis article to mailto:feedback@aspnetPRO.com.Please include the article title and author.