Performance/Load Testing/Stress Testing Using Fiddler

Introduction

 
The scope of this article is how fiddler can be used to do load or stress testing for a client-server-based application. Fiddler is a web debugging proxy tool that captures outgoing http/https traffic from a system(client application), that captured traffic can be used for further inspection like request, response and request statistic like time taken for the response, size of the response and lot more about the outing request from a client system. Fiddler is not designed to be used as a tool for load testing, however with a little customization we can extend this tool to perform load testing. In the next section I will explain why someone can consider fiddler for load testing though it's not specifically meant for that purpose. 
 

Why Use Fiddler for Load Testing?

 
There are lots of tools available specifically for load testing like load runner JMeter etc, then why use fiddler for load testing? Tools which are mostly designed for load testing require specific skilled resources to set up the test scripts and run them. So, in cases where we don't have this kind of tool, infrastructure, and the skills required to set up test script and run it, then with Fiddler can be used with little setup, without any specialized experience of doing load testing.
 
Apart from that setting up infrastructure and specialized teams to perform load testing with those tools involves time and cost, which can be avoided when time and cost is a factor to be considered. As Fiddler is a free tool and the approach of load testing with Fiddler does not need any specialized team to prepare load test script and run it, this can be used to save time to prepare for load testing and also the investment towards having an infrastructure and skilled resources. In my experience time was the factor when we thought of doing load testing for our application, as ETA was more to setup a load testing with those standard tools and we started looking for an alternative where we don’t have specialized resources and tools.
 
What do you need for load testing with Fiddler?
  1. Download and Install Fiddler in Client system (user system where application runs). Fiddler is free to download and install
  2. Basic knowledge of capturing a fiddler session and saving those sessions as .SAZ files. Fiddler sessions are the outgoing http/https request when you perform certain use case in your application keeping fiddler on.
  3. Fiddler sessions (.SAZ files) for use cases for which load testing will be done. These are the use cases frequently performed by users in production.
  4. Custom Fiddler script to generate load and capture results (scripts will be attached)
  5. Instructions to perform load testing
I will share more details on the above in subsequent sections of this article.
 

Approach of Load Testing with Fiddler

 
Basic idea is to capture out going http/https requests of frequent use cases for your application and replay those sessions in a certain interval within a load testing window. Custom Fiddler script will help in replaying captured sessions in a certain interval in order to simulate load for that session from .saz file. This way multiple .saz files which correspond to your load test use cases can be captured and run from multiple instances of Fiddler to generate load.
 
In order to generate a huge load one personal computer may not be enough, and in that case .saz files can be distributed among a group within a team and perform this test together from multiple PCs. At the end of the testing all simulated requests can be seen in fiddler instances whether requests are successful or failed. In our case we just generated the load using fiddler and checked performance results in Dynatrace (any application monitoring tool can be used) during the test window. In case you don’t have any application monitoring tool to check the health of your application under load testing, you may further customize the script using Fiddler API to generate a detailed report containing the number of requests made, number of failed requests, avg/median response time for a particular request. We haven’t implemented detailed test result generation, in case you feel it is required, you may contact me for any guidance on further extending this script.
 
Download and installation of fiddler is simple and does not require any specific instructions to be considered. Once you install and fiddler is ready to capture your application traffic and you have  basic knowledge of how to capture sessions for your application, we can proceed further with the steps required to perform load testing. For those who are not familiar with Fiddler, I will quickly explain how fiddler can be used to capture sessions for an application use case.
 

Basic knowledge to capture a Fiddler Session

 
For the purpose of not getting diverted from the actual topic, I will limit this to just how a .saz file can be captured for an application use case. Capturing outgoing traffic from a system is very easy, it only needs you to run fiddler and you will see all out going traffic from your system, as shown below in the screenshot
 
 
By default, Fiddler will capture all out going traffic from the system, it will include any application that is making an outgoing request and the captured sessions will include everything. In order to just capture outgoing requests for your application use case, you can use host filter mentioning your application root url and remove all captured sessions. Say your application root url is www.xyz.com, then you can set the host filter and remove all previously captured sessions like below in the screenshot
 
 
Now once you have the host filter for your application and have cleared all your previously captured sessions, you can start your application, now it will show only outgoing requests from your application. This way fiddler will now show the outgoing traffic only for the use case you are performing in your application. Once you are done with the use case, click on File->Save->All Sessions. This will save all sessions for your use case in .saz file (refer to below screenshot). Make sure before saving the session, it only has requests for your application.
 
 

Load Test Planning

 
Before you run the load test you need to identify which use cases you want to run during the load test window and on what the frequency those use case will be repeated. Based on the use cases you identified, create .saz file as mentioned in the previous section. Once .SAZ file is created for all your use cases, decide your test window and calculate the interval at which each use case will be repeated. You can create a table like below; the below table is for illustration purposes and will be different based on your load scenario.
 
Use Case
SAZ file
Load Window (in Sec)
Number of replays
Interval (in Sec)
1
UseCase1.SAZ
900
90
10
2
UseCase2.SAZ
900
60
15
3
UseCase3.SAZ
900
45
20
4
UseCase4.SAZ
900
30
30
 
Load Window =Duration of Load testing
 
Number of replays= Number of times the sessions corresponds to the use case will be submitted to generate the load during load window. Generally, this is the expected approx. number of users load within a duration of load window. These are termed as virtual users in load testing terminology.
 
Interval = Load Window/Number of replays
 
This plan is required based on the load you want to simulate. Each use case will be repeated with their corresponding interval within the load window. Each session needs to be triggered from multiple instance of fiddler, for multiple instance you can click on File->New Viewer.
 

Get your Fiddler ready for Load Testing

 
Once you are done with the planning, next thing is to set up custom script in fiddler to repeat your .saz file sessions with identified intervals. As the script used is in C#, before we setup the script we need to change the script option to C# by clicking Tools->Options->Scripting, change language to C# and this needs a restart of your fiddler in case it was Jscript.NET earlier. In order to setup custom script you need to click on Rules->Customize Rule, this will open Fiddler Script Editor. In Fiddler Script editor you need to replace existing script with the attached custom script and type Ctrl+S to save the script, it should get saved without any compilation error in script editor. The script implemented two commands,  load and run, load command loads the captured use case sessions from .SAZ file and run command resubmits the sessions with the mentioned interval to simulate the load.
 
Disclaimer
 
This setup will override any fiddler custom script that you already using.
 

Performing Load Test in Fiddler

 
The load and run commands can be run in Fiddler QuickExec, go to Fiddler and type Alt+Q to Open QuickExec. Commands need to be executed as below with the same order (first load command which loads the session from SAZ file and run command will start generating load based on the inputs to the command) for each SAZ file approximately at the same time.
 
load <Path of SAZ file>
run < Interval in millisecond> < Number of replays >
 
In order to run multiple SAZ files, multiple instances can be opened in fiddler by clicking File->New Viewer and repeating the  same step to run another SAZ file. In order to generate a huge load one personal computer may not be enough and that case .saz files can be distributed among a group within a team and perform this test together from multiple PCs. At the end of the testing all simulated requests can be seen in fiddler instances whether requests are successful or failed, what is the response time. etc. As I mentioned earlier, an application monitoring tool can be used to check the health of the application during load testing. In case you don’t have any application monitoring tool to check the health of your application under load testing, you may further customize the script using Fiddler API to generate a detailed report containing the number of requests made, number of failed requests, avg/median response time for a particular request. We haven’t implemented detailed test result generation, in case you feel this approach could be useful for you and you don’t have any APM tool, you may contact me for any guidance on further extending this script.
 
The approach of load testing using fiddler presented in this article is completely based on the requirement we had for one of our applications. The requirement and scenarios can be different for others, but I hope this will give you an idea about how fiddler can be utilized for Load testing. Based on some specific application requirements this can be further customized to make it more usable, you can customize or can contact me if any guidance is required to address any other challenges that you may encounter with your load testing scenario.
 
Finally, I would like to thank my colleague Shubham Sharma for ideating this and for making this approach successful for our requirement within the constraints we had.
 
Thanks for taking your time to read until the end, and I hope this will be useful for you at some point.


Similar Articles