2020 / 1 / 27
How to Handle Correlation in JMeter
Generally, if you visit a website, you will come across 2 types of content- STtatic and Dynamic Content. Static content is one that is fixed and pre-written and that will not change as per the user request. For example, Contact Us Page with company address and contact details is a static page. Now, if we see Dynamic Content, as the name suggests, dynamic content is generated based on the user request. If we take the example of a shopping website, suppose we are searching for software testing books in the search bar. A list of software testing books are retrieved from the database and displayed to the user as per the user query. Now, this we call dynamic content. I hope all of you must have a basic understanding of what static content and dynamic content is.
Now, if I want to test how a web server will handle static content and dynamic content, Approach is very simple for the static content. I will simply record a test script and execute it with multiple threads and that script would just run fine.
However, the majority of the websites that we see today are not that simple. They mostly have dynamic content, that JMeter needs to know how to capture that content and reuse it in subsequent requests. This is what correlation exactly means. Correlation is the process of capturing and storing the dynamic values from the web server and passing it on to subsequent requests.
In this blog post, our aim will be to discuss what is Correlation? Why do we need a Correlation? Is Manual Correlation the only option for the developers?
WHAT, WHY and WHERE?
Correlation is a very critical and crucial process during performance load testing. If it is not handled properly, the script will become useless.
Please Note Correlation can only be ignored in case of static content.
Let's look at a few scenarios to give you a better understanding of when the correlation is required.
Through these examples we just want you to get an idea of the situations where correlation is required. All you need to look for dynamic content and we are done with the decision.
Please Note JMeter doesn't have native auto correlation feature, so we have to perform correlation manually. You need to be more cautious while performing manual correlation, as you need to manually identify the correlation points in the test flow and maps the value to be replaced in consecutive requests.
How to do a Correlation?
Two basic steps are involved in performing correlation in JMeter:
If you have a small script, it is easy to determine the correlation points. But for a large script, determining correlation points is a very time consuming and error-prone task. For the large script, my advice would be to break it into small scripts and try to keep each individual small script atomic, which means they need to be as far as less dependent on each other.
However, this process consumes time, cost and also error-prone. So, it is advisable to automate the complete process of determining correlation points in test flow. There are many third-party tools out in the market that do this job of automating the task of identifying the correlation points in the test flow and then the generated JMX file can be imported and used in JMeter for further analysis.
In the next blog post, we will see in complete detail on how to manually correlate data.