Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

How to Handle Correlation in JMeter

DZone's Guide to

How to Handle Correlation in JMeter

We give a quick introduction to the process of correlation, how JMeter can help with this process, and how to automate correlation.

· Performance Zone ·
Free Resource

Container Monitoring and Management eBook: Read about the new realities of containerization.

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 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 a variable (e.g. "Add -> PostProcessor" components like the " Regular Expression Extractor ").

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

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.

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 terms of development 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.

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.

  • 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 the 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.

Since correlation is such an important part of scripting, it's recommended to automate the process, to avoid manual errors and to save time.

Take the Chaos Out of Container Monitoring. View the webcast on-demand!

Topics:
performance testing ,apache jmeter ,correlation ,load testing ,performance

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}