Check .NET Application Performance Using Performance Optimization

Introduction

Performance optimization is very subjective and it depends upon multiple factors like application architecture, design, and way of their implementation (coding). Before taking any action, first, need to check the area of improvement, and only then change can be done based upon their requirement. That’s why I decided to explain this topic in the series.

Before start, a performance check for any application, need to understand some basic requirements. It always depends on the business requirement that what is client benchmark, it is called NFR (Non-Functional Requirement) requirements. There can be scenarios where the client is saying “application performance is very poor” which itself a huge statement and as developers, they can’t easily understand that. Because as developers they want some figures like what is a current load that application can handle and what is the expected load that the client wants to meet. Based upon those measurements they can start work and take actions appropriately.

Background

Now the question is, how to check the current load of exiting applications which I will explain step by step.

Application performance can be measured based on the following four factors.

  • Response time: The time duration between the user sending the request and the system display response means the time difference between the HTTPRequest send and the HTTPResponse received at the client end.
  • Throughput: Total number of requests that a server can handle per second. For E.g. 1000 transactions can be handled per second.
  • Resource Utilization: Resource utilization cost is calculated based on server and Network resources. Resources that are consumed during request processing are,
    • CPU
    • Memory
    • Disk I/O
    • Network I/O
  • Workload: How much user load the application can handle on the server? There can be two types of user load simultaneous users or concurrent users.
    • Simultaneous users: Have active connections to the same Web site.
    • Concurrent users: Hit the site at exactly the same moment.

To check this practically, I used the Visual Studio Performance Test against my application and verified the results as it is easy for any .NET developer. You can use any other tool like Load Runner, jMiter, etc.

Create a Performance Test

Firstly, I will explain how to check performance for web-based applications step by step.

Step 1. Copy web site URL that needs to be tested and that can be your local machine URL e.g.http://localhost:16260/Account/Login. Note down all the steps and input data that need to be captured during the performance test.

Step 2. Open Visual Studio and create a new project of type Web Performance and Load Test Project as in the following.

Web Performance

Step 3. Open the .webtest file and select Add Recording. The same can be done by right-clicking the web test file and selecting Add Recording.

Add Recording

It will open Internet Explorer and there will be a recording toolbar on left hand side.

 Internet Explorer

Step 4. Click the Record button and paste the required URL in the browser run the web application and execute required functionality. It will start recording all HTTPRequest and HTTPResponse details including dynamic data (input fields). After recoding completion you will see the Web performance test in the Web Performance Test Editor as a list of URLs. Here editing can be done.

HTTPRequest

Edit Performance Test

Step 1. Open the .webtest file and there will be a list of requested URLs (called a request tree).

Step 2. Select any URL and check their properties (as shown in the above image). It shows properties related to HTTPRequest and HTTPResponse. Notice that the Think Time for this request is a number greater than 0. This is how many seconds you take before sending a second request. Means you send the first request at 01:01:10 and the second request at 01:01:20 then its value will be 10 seconds. In the above image, you can see its request for the login page, and after successful authentication, it routes to “Admin/Default.aspx”.

Step 3. To change the Think Time value, click Set Request Details and it will open a window for request and set values 1 or whatever you want to put as per your requirement.

Set request

Here you can set the following values.

  • Reporting names: Reporting names make it easier to identify specific Web requests in the Web Performance Test Results Viewer and when you create Excel reports.
  • Think times: Artificial human delay times between Web requests.
  • Response time goals: Seconds you want to set as a goal for the response time on a Web request. This is very important if you want to check whether your page processes successfully or not in a specified time duration.

Step 4. Select any URL and expand Form Post Parameters. Here you can provide the requested parameter that you want to provide and also the URL Expected HTTP Status Code property value. Like if you think there should be an exception from the server side based upon a particular parameter then provide a server response to 500 or any other HTTP Response value.

Apart from that, you can also specify Validation and Extraction rules like the Web application is working correctly by validating that text, tags, or attributes exist on the page that is returned by a Web request. But that is not our scope as we need to concentrate only on application performance, not application functionality validation.

Next when the test runs it will use these performance parameters for all web requests.

Run and analyze test results

Step 1. Web Performance Test Editor, choose Run Test (as shown in the above image) on the toolbar. Here you will see the progress in all the web requests that you have done during recordings with updated parameter settings.

Step 2. In the Test Results Viewer window, If it is green then all things went fine and as per your expected results, and if it is red then there is some issue with the result and it fails your result expectations.

Test Results

Step 3. Now change the Response Goal more realistic value and see where your page able to achieve that target or not. Here we set the Response Goal to 1 sec.

Change Response Goal

Step 4. Run the performance test again and see the results. Here you will see it failed and to see error details, Select test case in the Test Results Viewer window and right-click then select View Test Results Details. Here you can see a detailed description of an error like where exactly the issue occurs and what the reason is for the same.

View Test Results

In this article, you learn how you can check performance for any web page. You can create multiple Web Performance test cases for a different module like Customer, Admin, and Manager Roles. Because during the load test, there will be a different requirement for each type of module e.g. for an eCommerce site Customer load will be more than Admin and Manager. So performance for modules that are mostly used by end-users like Item Search, Add to Card, and Checkout should be more targeted.

In my next article, will explain how this web performance test will behave under heavy load. There you can also see server resource consumption done by your application.

Reference: Web Performance Test Walkthroughs.


Recommended Free Ebook
Similar Articles