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 improvements, 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 that measurements they can start work and take actions appropriately.
 
Background
 
Now question comes, how to check current load of exiting application which I will explain step by step.
 
Application performance can be measured based upon the following four factors.
  • Response time: Time duration between users send request and system display response means time difference between HTTPRequest send and HTTPResponse received at client end.
     
  • Throughput: Total number of request that a server can handle per second. E.g. 1000 transaction can handle per second.
     
  • Resource Utilization: Resource utilization cost calculated based upon server and Network resources. Resources that consume during request processing are:
     
    • CPU
    • Memory
    • Disk I/O
    • Network I/O
       
  • Workload: How much user load that application can handle on 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 Visual Studio Performance Test against my application and verify 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 need 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 capture during performance test.
 
Step 2: Open Visual Studio and create new project of type Web Performance and Load Test Project as in the following: 
 
Web Performance and Load Test
 
Step 3: Open .webtest file and select Add Recording. Same can be done by right-clicking webtest file and select Add Recording.
 
Add Recording
 
It will open Internet Explorer and there will be recording toolbar on left hand side.
 
Record
 
Step 4: Click Record button and paste required URL in browser and run 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 Web performance test in the Web Performance Test Editor as a list of URLs. Here editing can be done.
 
Web performance
 
Edit Performance Test
 
Step 1: Open .webtest file and there will be a list of requested URLs (called 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 Details
 
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 to you want to check whether your page process 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 URL Expected HTTP Status Code property value. Like if you think there should be an exception from the server-side based upon particular parameter then provide server response to 500 or any other HTTP Response value.
 
Apart from that, you can also specify Validation and Extraction rules like 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 run 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 Test Results Viewer window, If it is green then all things gone 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 Response Goal more realistic value and see where your page able to achieve that target or not. Here we set 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 Details
 
In this article, you learned 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 load test there will be a different requirement for each type of module e.g. for eCommerce site Customer load will be more than Admin and Manager. So performance for modules that are mostly used by end-user like Item Search, Add to Card, Checkout should be more target.
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.
 


Recommended Ebook

.NET Interview Questions and Answer: Practical Implementation

Download Now!
Similar Articles