Recipe 10.8 Stress Testing a Web Application or Service

     

10.8.1 Problem

You want to stress test your ASP.NET web application or service to analyze its performance and identify any scalability problems.

10.8.2 Solution

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:

  1. Add a new Application Center Test project to the Solution Explorer (available under Other Projects in the Project Types list).

  2. 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.

  3. 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.

  4. 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
figs/ancb_1006.gif

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
figs/ancb_1007.gif

10.8.3 Discussion

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
figs/ancb_1008.gif

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.



ASP. NET Cookbook
ASP.Net 2.0 Cookbook (Cookbooks (OReilly))
ISBN: 0596100647
EAN: 2147483647
Year: 2006
Pages: 179

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net