You want to stress test your ASP.NET web application or service to analyze its performance and identify any scalability problems.
Use the Application Center Test (ACT), included in the Enterprise Architect and Enterprise Developer editions of Visual Studio .NET, to simulate a large group of users by opening multiple connections to the server and rapidly sending HTTP requests . The easiest way to accomplish this is to record a test script and then modify the test properties to match the stress test you want to simulate. In the case of a web service, you can record the steps you'd take to manually enter settings into the web service's test page, and then have the ACT tool automatically replay the test script to simulate a large number of users simultaneously accessing the service.
For example, to stress test our sample web service in Recipe 11.1, follow these steps:
Add a new Application Center Test project to the Solution Explorer (available under Other Projects in the Project Types list).
Click on the new ACT project in Solution Explorer, select File Add New Item from the menu, and choose "Browser Recorded Test (.vbs)" from the list of templates.
Start Browser Record mode and when the browser opens, navigate to the web service's ASMX page, choose a method to stress test, enter the appropriate values (as shown in Figure 10-6), and invoke the method.
When you see the XML returned by the web service, click Stop on the recorder dialog box.
Figure 10-6. Settings for stress testing a sample web service
You'll then see the contents of the . vbs script where you can edit commands as necessary, as shown in Figure 10-7. You can also use the Properties window to modify the number of simultaneous browser connections (also known as the stress level ), iterations or time in seconds to run the test, test warm-up time, and the like. Start the test by right-clicking the . vbs file in Solution Explorer and choosing "Start Test."
Figure 10-7. ACT test script within VS.NET
Stress testing is the process of assessing your web applications or services under load. It allows you to determine how well your applications or services scale under the stress of user demand.
Although you can record and run a stress test within Visual Studio .NET, there are distinct advantages to using ACT's standalone user interface instead. Besides being easier to work with, the standalone UI provides more in-depth reporting information and graphs, as shown in Figure 10-8. For example, it provides the only way to add additional performance counters to a report.
Figure 10-8. Results of a stress test in ACT
ACT tests can run for either a length of time or a number of script iterations. When setting the number of iterations, be aware how it relates to the number of simultaneous browser connections. The number of requests that are issued for the test is the product of the two settings. For example, if you set the number of iterations to 10 and the simultaneous browser connections to 10, the web service will actually receive 100 requests before the test completes.
When stress testing a web service, you can learn a lot by estimating what the expected production load will be and setting the stress level accordingly . Another good approach is to hike the stress level to the point where you start to see significant numbers of HTTP, Socket, and/or DNS errors. You can then iterate on the stress level to find out the web service's maximum capacity. In the process, you wind up better understanding where the bottlenecks exist in your software, hardware, and network capacity.