Vincenzo Marrazzo is a Test Automation Specialist. He has over 14 years of experience in various contexts both with open-source technologies and commercial ones. His primary activities are Test Automation and Performance Test. Vincenzo currently works at Capgemini Engineering Italy.

Become a JMeter and Continuous Testing Pro

Start Learning

Test Your Website Performance NOW! |

arrowPlease enter a URL with http(s)
Oct 23 2017

How to Handle Correlation in JMeter

What is Correlation in Load Testing?


Correlation is the process of capturing and storing the dynamic response from the server and passing it on to subsequent requests. A response is considered dynamic when it can return different data for each iterating request, occasionally affecting successive requests. Correlation is a critical process during performance load test scripting, because if it isn’t handled correctly, our script will become useless.


From a testing point of view, it is necessary to identify which response is dynamic and which is static (the data stays the same for iterating requests). Typically every HTTP web performance test involves data correlation. You can ignore correlation only if you are testing static content pages, like some homepages and contacts. In other cases, you can’t avoid correlation handling at some point of the test.


To better clarify this point, here are some examples:


1. The test requires evaluating the response time of static content with a specific network condition (e.g. proxy, gateway, etc). - When the specification is for static text in the response, there is no need for correlation, because the requirement focuses on the invariance of the content response.


2. The test requires that after creating a post on a blog, the user can perform one of many different actions. - Correlation is definitely involved in this step because the “creation” action involves dynamic content that must be handled (eg. page Id, url path, etc).


3. After user authentication, the created session cookie must be… - No correlation step is necessary here because this step has authentication cookies, which can be handled with JMeter’s “HTTP Cookie Manager” component. In terms of data, this actually is a correlation, but JMeter already has a component that can handle this kind, so we don’t need to correlate ourselves.


4. When a user lands on a web application, the server assigns her/him a session id. This id is used by the application to handle the user’s interaction. - This situation quite surely involves correlation, so it's necessary to investigate which application logic should be replicated, with correlation, in the successive requests.


5. During user navigation, the application assigns a specific condition to a cookie that alters the successive navigation steps - this one is tricky! If the information handled in the cookie is read from the cookie cache, you can handle the cookie (as already seen) with the “HTTP Cookie Manager” and not correlate. In any other case, this is quite surely a correlation activity.


Manual Correlation in JMeter


Manual Correlation means that the developer manually discovers correlation points in the test flow and maps the values to be replaced in consecutive requests.


Correlation in Apache JMeter™ is handled in two steps:


1. Extracting dynamic data from a key request and assigning it to variable (e.g. “Add -> PostProcessor” components like the “Regular Expression Extractor”)


2. Reusing a variable in every occurrence that involves dynamic data.


jmeter correlation


In the picture above you can see a “Regular Expression Extractor”, which extracts information from the body of the previous sample. Following this component, the successive requests can use the variable ${data-cmsid}, which will be dynamically mapped during execution. Learn more about how to manually correlate from this blog post.


This procedure is the common way to manually correlate with JMeter. It requires a deep investigation of the application to see where correlation is required.


Making Manual Correlation Easier


If you have a small script with only a few correlation points, you can correlate manually. But when your script is large and has a lot of correlations, handling tends to be time consuming and error prone for manual correlation.


Based on my experience, before starting to work on a potential “large script” with a lot of correlation points, it’s better to improve your analysis on the test requirements. You can do that by breaking down the large test into smaller test requirement subsets. If possible, each subset should be atomic, in term of developing and execution.


The final scope of the breakdown process is to have a small script that can be aggregated/sequenced into a final run scenario, maybe even directly in JMeter’s UI. However, this breakdown process requires time and effort, which come at a cost.


It would be much easier if correlation could be automated.


Auto-Correlation in JMeter


JMeter does not provide a native auto-correlation feature in its desktop application. However, you can use BlazeMeter’s free SmartJMX, which is included in the BlazeMeter Proxy Recorder. The recorder generated a JMX script, based on a recorded scenario, which is automatically correlated.


Auto-correlation in SmartJMX Key Points


  • SmartJMX is free and part of Blazemeter’s Proxy Recorder Technology. You can sign up here.
  • The Proxy Recorder Technology does not require installation because it is entirely on the web workspace.
  • SmartJMX supports HTTP web recording for web, mobile browsers and native mobile apps. It’s suitable for any application based on HTTP.
  • After recording, the JMX file is available for post processing on your local JMeter. After recording your script, the SmartJMX button appears. By clicking on it you will get a JMX file with all the correlation points automatically identified.


how to handle correlation on jmeter


Since correlation is such an important part of scripting, it’s recommended to automate the process, to avoid manual errors and to save time. To learn more about how to work with SmartJMX and its benefits like clean up and automatically adding configuration items, click here.


Now that you’ve covered correlations, expand your JMeter knowledge with our free JMeter Academy. We offer completely free basic and advanced JMeter training.


Try out BlazeMeter! Put your JMX file or URL in the box below and your test will start in minutes. Or, request a demo.


Click here to subscribe to our newsletter.

arrowPlease enter a URL with http(s)

Interested in writing for our Blog?Send us a pitch!