Return to PerformanceTestingGuidance





How To: Load Test Web Applications Using VS.NET 2005


Applies to

VS.NET 2005
Performance Testing

Summary

This How-To creates a Load Test using Visual Studio 2005 for a real world application. To create a load test first you will need to understand the customer scenario with use case scenarios, the workload profile, the performance objectives and metrics. Then you will create individual Web tests that simulate the use case scenarios. At the end a Load Test will be generated, containing the Web tests for the use case scenarios, distributed as in the workload profile, with many runtime properties to generate desired load simulation according to the workload characterization, and the performance counters to be monitored, identified in the performance metrics.

Overview

Use load testing to verify application behavior under normal and peak load conditions. This allows you to verify that your application can meet your desired performance objectives. Load testing enables you to measure response times, throughput rates, resource utilization levels, and to identify your application's breaking point.
This how to walks you through with a practical scenario for a hypothetical customer.

Scenario

		 Web based eCommerse site with the following performance workload characteristics, extracted from the Weblogs in production:
	
* 2000 searches per minute
* 100 orders per minute
* 124 new registration per minute
* 2500 hits home page per minute

The workload profile from the web logs indicated the following distribution:

Searches Login->Browse->Search->Logout 80%
Orders Login->Browse->Search->addtoCart->Order->Logout 10%
Registration Login->RegisterUser->Browse->Search 5%

From the business requirements the following set of objectives were gathered

Under Normal load
* Able to complete 100 orders per minute with response times below 6 seconds
* Able to do 2000 searches per minute with response time below 8 seconds
* Users should be able to login at 1500 per minute with response times below 4 seconds

With Peak loads
* Able to complete 200 orders per minute with response times below 10 seconds
* Able to do 4000 searches per minute with response time below 12 seconds
* Users should be to login at 3000 per minute with response times below 10 seconds


Summary of Steps

* Step 1 – Create a Test Project
* Step 2 – Create a Web Test
* Step 3 – Record Your Web Test
* Step 4 – Replay Your Web Test
* Step 5 – Add Your Load Test
* Step 6 – Specify Your Scenario Settings
* Step 7 – Specify Your Load Pattern Settings
* Step 8 – Add Your Web Test to Your Load Test
* Step 9 – Specify Your Browser Mix
* Step 10 – Add Your Network Mix
* Step 11 – Specify Your Computers and Counter Settings
* Step 12 – Specify Your Run Settings
* Step 13 – Run Your Load Test

Steps

Step 1 Create a Test Project

Create a test project called CustomerScenario, by default it will have an empty unit test, within the business web site created. We will add Web Test and Load Test to this project in later steps.

Creating a Test Project

* This will open the New Project dialog box.
* In the New Project dialog box, in the left hand pane, expand the Visual C# node, and select Test.
* In the right hand pane select the option Test Project, name your test project TestProject1, and then click OK.












Step 2 Create a Web Test

In this step, you create a Web test. The Web test will be used in your Load Test. The Web test simulates how an end user will interact with the Web application.

Creating a Web Test

  1. In Solution Explorer, right-click TestProject1, select Add, and then select Web Test.

Step 3 Record Your Web Test

  1. The Web Test Recorder opens inside a new instance of Internet Explorer.

For this How to we are creating Web test by recording HTTP requests using the Web Test Recorder in a browser session, but you can also build Web tests manually using the Web Test Editor.

For this how to we will be recording a Web Test for all the scenarios identified in scenarios section:
* Orders
* New Registrations
* Searches

Recording Your Web Test

  1. In the Address bar, replace about:blank with the URL address for the three scenarios.
  2. When you press Enter, the page is processed and rendered in the browser window. The actions are recorded for subsequent playback when you run the test.
  3. Go through various steps to create your scenarios.

Step 4 Replay Your Web Test

Replay your Web test to make sure it works. Fix the failure, if it occurs, before you add the Web test to the Load test, since it’s simpler to debug here, debugging from load test can be a painful process.

Replaying Your Web Test

<<we need to show the UI. Another way to run the web test is from test manager/test view
Click test->windows->Test Manager/Test view and right click on the web test select run selection
I do not see the third option Or you can right click the Web test and choose the option Run Web Test>>

  1. In the main window of Web test click the Run Test button in the left hand corner. Or you can right click the Web test and choose the option Run Web Test.
  2. The Web test will be run for a single user, and result displayed in the main window as shown in the figure.
  3. Analyze and make sure there are no errors in any of the requests.



More Information

The purpose of replaying your Web test is not merely to ascertain if the Web Test passes or fails. Here are the things you might want to check before adding the web test to a Load Test.
* Check if any of the top request or dependent request has failed, the failure reasons could be URLs called through JavaScript, ActiveX controls, Applets. These problems arise because the recorder can only record requests coming from the Web browser. If you experience any one or more of these problems, you can manually add the necessary requests to the recorded Web test. For more information, see "About JavaScript and ActiveX Controls in Web Tests" at http://msdn2.microsoft.com/en-us/library/ms404678(VS.80).aspx . Fix the failure before you add the web test to Load test. This is important because debugging from load test can be painful process.
* Verify that the response time for each request meets the requirements for single user, such as 5 second or less for intranet applications and 8 seconds or less for internet based applications. If yes, then only go ahead with adding your Load test step. If not, investigate the reason for delayed response time and fix the issue.
* Verify that the file sizes of top requests and dependent requests meet the requirements. If yes, then only go ahead with adding your load test step. If not, try and fix the underlying issue.

Step 5 - Put transaction break points

Put the transaction break points around the processing of critical scenarios identified in scenarios section, where performance metrics are necessary.
* Posting of an order
* Searching for a product
* Posting the new registration of an users

Step 6 - Put the data binding into transactions that needed it

Add data binding where parameterized values need to be replace during runtime
* Product id when posting of a new order
* Product Id when searching for a product
* User id when doing the new registration of an user

Step 7 Add Your Load Test

In this step, you add the Load Test to the TestProject1 project. Subsequently we will add the Web Test to the Load Test, which will simulate the load while executing the Web test. You will then set various properties of your Load Test in subsequent steps.

Adding Your Load Test

  1. In Solution Explorer, right-click the TestProject1 project node. Select Add, and then click Load Test.

  1. The New Load Test Wizard starts.
  2. The Welcome page of the New Load Test Wizard is the first page.
  3. Click Next.



  1. Step 8 Specify Your Scenario Settings
Specify name of your scenario. We are performing Load Test for browsing catalog scenario, so the scenario name could be "Browsing Catalog."
  1. Set the Time Profile Think to Use normal distribution centered on recorded think times. This will use the recorded times from Step 3. Record Your Web Test. Think times represent the time that a user would ponder a Web page before going on to the next page. For this exercise, the think time will be the time spent by user to read the catalog and choose a category and narrow down to an item



More Information

The choice of Think Time Profiles depends upon intend of usage.
* By choosing to use recorded think times, Think times are used exactly as they were recorded in the Web test. Because a load test simulates multiple users, using the same think time could create an unnatural load pattern of synchronized virtual users.
* By choosing normal distribution, think times are used, but varied on a normal curve. Provides a more realistic simulation of virtual users by slightly varying the think time between requests.
* By choosing not to use think time, the think times are ignored. This does not provide realistic user interaction with the application. This should be used only when you are doing performance tuning, where you are concerned about throughput rather then real user experience.
For more information on Think Time, please see " About Think Times" at http://msdn2.microsoft.com/en-us/library/ms184790(VS.80).aspx




Step 9 Specify Your Load Pattern Settings

From the scenario load patterns specify the number of concurrent users with warmp-up time of 10 minutes

Under Normal load
* Able to complete 100 orders per minute with response times below 6 seconds
* Able to do 2000 searches per minute with response time below 8 seconds
* Users should be able to login at 1500 per minute with response times below 4 seconds

With Peak loads
* Able to complete 200 orders per minute with response times below 10 seconds
* Able to do 4000 searches per minute with response time below 12 seconds
* Users should be to login at 3000 per minute with response times below 10 seconds

Step 10 Add Your Web Test to Your Load Test

For all the scenarios identified in the scenario section add the Web test with the correct percentage distribution.


Searches Login->Browse->Search->Logout 80%
Orders Login->Browse->Search->addtoCart->Order->Logout 10%
Registration Login->RegisterUser->Browse->Search 5%

Step 11 Specify Your Browser Mix
In this step, you add the browser mix by specifying types of browsers being used and distribution ratio for each type of browser.

<<this is a step 0 baseline doc. We should be using only Internet explorer option>>

Specifying Your Browser Mix

  1. From the drop-down list of browser types, select the IE6 browser to add to the mix.
  2. As our web site is internet facing web site we would be adding Netscape 6.0 as well, Click Add button from the drop down select Netscape 6.0.
  3. Adjust the distribution of IE user and Netscape as 88% IE and 12% Netscape (based on industry trends).
  4. Then click Next.

More Information

The browser mix is a combination of two factors. The first factor is browser types. The second factor is the distribution. The types of browser which are being supported can be determined from the requirement specs or service level agreement.

For a new web application, the browser distribution is decided by the requirements or industry trends and is set in terms of percentage.

For existing web application, the browser distribution is decided from the information extracted from IIS logs.

Step 12 Add Your Network Mix

In this step, you add the network mix by specifying types of network, on which the application is accessed and distribution ratio for each type of network.

Specifying Your Network Mix

<<we should be using default lan only. This is a baseline step 0 doc>>
  1. As our Web Site is internet facing and users from various location are expected to use the Web site, it will be mix of DSL and dial-up connection.
  2. From the Network Type drop down, select the Cable / DSL 1.5 Mbps connection type.
  3. Click Add button and select the Dial-up 56K.
  4. Let the distribution be 50% each.
  5. Then click Next.


More Information

Network mix, is a combination of two factors. The first factor is network types. The second factor is the distribution of network types. The types of network which are being supported can be determined from the requirement specs or service level agreement. Depending upon the requirements or industry trends the network mix distribution can be decided and set in terms of percentage.

Step 13 Specify Your Computers and Counter Settings

Add the Performance counter settings for the web and sql server
process(w3wp.exe) *
Memory *
Clr Exception *
Clr Locks and Threads *
Clr Memory *
Logical Disk *
Network Interface
total\Bytes/sec
Output queue
Logical Disk *
Processor time


Step 14 Specify Your Run Settings
In this step, specify set of properties which determine how the Load test runs. The run settings determine the length of the test, warm-up duration, maximum number of error details reported, sampling rate, validation level etc.
By default the Warm-up duration is 0, Run duration is 10 minutes, Sampling rate is 5 seconds, Maximum error details is 100 and Validation level is Low.

Specifying Your Settings

		  <<validation level default is low. This is minimal step 0 baseline type of document
	
I am reviewing with this mind set. Just take in this how to the defaults>>
  1. On the Run Settings page choose your initial settings.
  2. Specify the Warm-up duration in hh:mm:ss format. This is the period between the beginning of the test and when the data samples start being recorded.
  3. Specify Run duration in hh:mm:ss format. This is the actual length of the test.
  4. Specify Sampling rate in seconds. This is the interval at which to capture performance counter values
  5. In the Description edit box specify the description of the Run Settings.
  6. Specify the Maximum error details, this is the maximum number of request and response details of failed requests that are stored. This is important because detailed error results can consume a large amount of database storage. If you do not want to record error details, use a value of 0.
  7. Specify the Validation level. This defines the highest level of validation rule that will run in a load test. Validation rules are associated with Web test requests. Each validation rule has an associated validation level; high, medium, or low. This load test running setting will specify which validation rules will run while the Web test is run in the load test. For example, if this run setting is set to Medium, all validation rules marked as medium or low will be run.
  8. Click Finish. Your Load test is opened in the Load Test Editor.
!

Step 15 Run Your Load Test

In this step you run the Load test to see, how the Web application responds to the web test, under the load simulation.

Running Your Load Test

  1. In the Load Test Editor right click on the Load Test and select Run Test option.
  2. Click View menu in main window then select Full Screen, this will maximize the viewable area.
  3. Once the Load test is complete, it displays a message, "Load Test 'LoadTest1' is complete. The test data currently displayed only represents a portion of the available results. Would you like to view the detailed results from the load test result store?"
  4. Click Yes on the message.



More Information

The threshold violation, errors, warnings are displayed with different colors and icons. Counters violating thresholds can be dragged onto the graph, to generate the violation graph. This can be done while the test is running.

What to Do Next

You can analyze the data from your load test runs to locate bottlenecks, identify errors, and measure improvements in your application.

* In the left hand pane "Summary", of the results window, indicates the total tests (user sessions executed) with failure count. Here you can find if any of the requests has failed.



* If any errors occurred, an errors hyperlink appears on the load test status bar and specifies the number of errors that occurred. To display the errors table, you click the hyperlink.



For more information see, "Analyzing Load Test Errors" at http://msdn2.microsoft.com/en-us/library/ms404697(VS.80).aspx

* If any violations occurred, a threshold violations hyperlink appears on the load test status bar and specifies the number of violations that occurred. You click the hyperlink to display the threshold violations table.



For more information, see "Analyzing Threshold Rule Violations" at http://msdn2.microsoft.com/en-us/library/ms404694(VS.80).aspx

Resources

* Walkthrough: Creating and Running a Load Test: http://msdn2.microsoft.com/en-us/library/ms182594(VS.80).aspx
* Working with Load Tests: http://msdn2.microsoft.com/en-us/library/ms182561(VS.80).aspx
* Testing .NET Application Performance: http://msdn2.microsoft.com/en-us/library/ms998581.aspx
Improving .NET Application Performance: http://msdn2.microsoft.com/en-us/library/ms998530.aspx

Step 16 analyze results

Microsoft Communities