info@pragmatictesters.com +94 11 253 8512

Efficient use of available resources is very important in JMeter performance testing, especially when you want to simulate a large number of virtual users, process large amounts of data and requests.

You need to ensure that your operating system is fine tuned and sufficient storage available for performance testing in addition to the JMeter configuration. 

In this post you will learn ten ways to use the available system resources efficiently through JMeter configuration.

1 Use CSV files for random test data

Creating random test data at runtime is an expensive process in terms of CPU and memory usage. Hence it is advisable to create the test data in CSV format in advance and read them through CSV Data Set Config Element.

2 Run the test in CLI mode

Running tests in command line mode (CLI, headless or non-gui mode) reduces the resource consumption.

jmeter -n -t test.jmx -l test.jtl

CLI mode options 

GUI mode should be used for creating the scripts and debugging only.

3 Use the latest versions

JMeter’s performance is constantly improving. Hence it’s advisable to use the latest stable version of JMeter. Please see the release notes for the improvements.

JMeter is compatible with Java 8 or higher. It is highly advised to install the latest minor version of your major version for security and performance reasons.

Also it is recommended to use the latest version of the plugins too. Checkout the relevant release notes for the performance improvements if any.

4 Remove Unnecessary plugins

When you try out with JMeter plugins you may have added plugins not required for specific project.You can use the JMeter plugins manager to uninstall the unnecessary plugins. It will improve the JMeter startup time 

Optionally you could open a JMX with plugins  from a fresh installation with plugins manager. JMeter Plugins Manager will list the missing plugins. You can install the plugins.

5 Use listeners with care

   Following points will be useful when you use JMeter listeners. 

  1. Do not use resource consuming listeners such as View Result Tree, View Result Table, Graph Results, Assertion Results , Aggregate Report,  during load tests. Use them only for debugging and script creation
  2. Save test results in CSV format as they consume lesser resources as compared to XML format 
  3. Save the only required fields. Configure the minimum required test results fields through configure window 
  4. Use fewer listeners as possible 
  5. Listeners do not process sample data in CLI mode.
  6. Use the Simple Data Writer to write test results into files

It is recommended to generate the test reports at the end of the testing to ensure the resource is available to the JMeter at the time of the test execution.

6 Increase the Java Heap size

Increasing the Java heap size is the one of the most important and popular configurations to improve the performance of JMeter. You can configure the heap size by setting the environment variables associated with the heap size.

By default the heap size is set to 1 GB. You can increase the size by setting the environment variable. You can allocate upto 80% of available RAM in the JMeter client/server. Use a bigger heap, but a smaller metaspace, than the default

On Mac/Linux

export HEAP="-Xms1G -Xmx1G -XMaxMetaspaceSize=192m"

On Windows

set HEAP=-Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m

7 Use of Scripting Language

When you do advanced testing, available JMeter components with their setting many not be sufficient. You will have to use scripting/programming to achieve the desired user scenarios, process data etc. It’s important to select a scripting language, JMeter components and their configurations for the performance.

  1. It is recommended to use Groovy over Beanshell and JavaScripts 
  2. Use JSR223 Elements over BeanShell for better performance 
  3. Use scripts file instead of inlining the script for pre-compilation and caching 
  4. If inline scripting is used, select the  Cache compiled script if available property to ensure the script compilation is cached 
  5. Migration from BeanShell to JSR223 + Groovy is highly recommended

8 Select efficient post processors  

  1. Use CSS Selector Extractor for extracting values from HTML instead of XPath Extractors considering better performance 
  2. Migrate from BeanShell Post processors to JSR223 Post processors with Groovy for better performance
  3. Fields to check in Regular Expressions Extractor should be selected carefully as some of them has effect on the performance
  4. Use XPath2 Extractor over XPath Extractor for better performance

9 Use of Assertions

Assertions are used for additional checks on the sampler results and processed after every sampler in the scope.

  1. Use fewer assertion minimize the resource consumption 
  2. Don’t use heavy resource consuming assertions during the load tests. Compare Assertion
  3. Migrate from BeanShell Assertion to JSR223 Assertions for performance improvements

It’s not recommended to perform many verifications (add many assertions)  as in the functional testing in performance testing. Functionality verification is not in the scope of performance testing.

10 Use variable expression in IF controller

Check  “Interpret Condition as Variable Expression” and use a recommended option for better performance in the If Controller.

Option 1 : Use a variable that contain true or false

Option 2 : Use a function to evaluate an expression that must return true or false

Examples 

${__groovy(vars.get("myVar") != "Invalid" )} 

${__groovy(vars.get("myInt").toInteger() <=4 )} 

${__groovy(vars.get("myMissing") != null )} 

${__jexl3(${COUNT} < 10)}

It is NOT recommended to use Javascript expressions due to performance issues 

Javascript Examples 

${COUNT} < 10

"${VAR}" == "abcd"

Author: Janesh Kodikara

Performance Tester | JMeter Trainer | Software Testing Service Provider

Your Turn To Talk

Leave a reply:

Your email address will not be published.