JMeter. Changing intensity with Constant Throughput Timer
In JMeter, it is no longer possible to change the intensity, the number of threads and the duration of the test by standard methods after starting the test. However, it happens that the test is already running, but you urgently need to change a parameter (for example, I often forget to indicate the test duration), for which you need to stop the test, set database to the initial state, reboot the cluster, pull the original git commit and so on. Solution: configure and run BeanShell Server. With the help of BeanShell Server one can “play” with the following settings. Let’s illustrate it on the example of intensity change.
Table of Contents
- Variables
- JMeter configuration and start from the command line
- Explanation
- Example solution for a maximum search test
- Conclusion
Variables
jmeter_loc – the full path to the root jmeter folder
host, port – jmeter’s host and port for the machine, where it is running
bsh_loc – folder, containing bsh-files
new_throughput – new intensity value, op/min
old_throughput – default intensity value, op/min
JMeter configuration and start from the command line
1. We create the file name.bsh: «setprop(“hits”,args[0]);»
2. In jmeter.properties search for: «BeanShell configuration» and comment out the lines «beanshell.server.port=9000» и «beanshell.server.file=../extras/startup.bsh».
3. After rebooting jmeter the server start line appears in the command line window:
4. Set target throughput to ${__P(hits, %old_throughput%)}.
5. If needed during the test we set the new throughput from the jmeter root folder in cmd to: «java –jar %jmeter_loc%\lib\bshclient.jar %host% %port% %bsh_loc%\name.bsh %new_throughput%».
Explanation
In the line «java –jar %jmeter_loc%\lib\bshclient.jar %host% %port% %bsh_loc%\name.bsh %new_throughput%» we call bshclient and indicate, which host and port are opened to the bsh-server, as well as which bsh-script needs a new parameter.
Example solution for a maximum search test
The project profile consisted of 20+ operation, so changing each intensity change manually is not fun. We wanted to find a maximally scalable and parametrized solution, which would allow us to use it for different projects with a different operation amount and from different loading machines.
Let’s illustrate it on the example of intensity change.
In the end we’ve written a “universal” .bat-file to change intensity,
where vals-line contains new intensity values, separated by letter “a”.
name.bsh:
In jmeter scenario we add a separate thread group and in it – jsr223-sampler. Constant timer is added to the thread group and the intensity change is fired by it. Base intensity values for each iteration are saved in User Defined Variables.
Function Helper explains, how to use intensity values syntax in Target Throughput.
After the .bat-file has been executed, the command line stays open, so we see that the intensity values have successfully been changed.
And that the command has looked like that:
java -jar C:/Users/User/Desktop/apache-jmeter-5.1.1\lib\bshclient.jar localhost 9000 C:/Users/User/Desktop/apache-jmeter-5.1.1/bsh\name.bsh 1344 2016 2016 240
We observe the intensity change in Transaction per Second:
The intensity has been doubled.
Conclusion
Using the described approach, you can increase and reduce intensity, thread amount and test duration, which saves time and helps to choose the optimal load options.
Related insights in blog articles
PFLB is NOW SOC2 Compliant
The PFLB team is happy to share the good news. We have passed the SOC 2 compliance accreditation. It means we can assure our clients that our cooperation will be entirely secure. What Is SOC? Introduced by the American Institute of CPAs (AICPA), SOC, or Service Organization Control, is a cybersecurity series of reports made […]
How Do Businesses Benefit from Frontend Performance Testing?
Crucial bottlenecks are usually backend-related. That’s why backend performance testing is generally regarded as a must. However, only 1% of companies perform frontend performance testing. They don’t consider that to achieve the best business results, one should combine the two types. Let’s prove it. We will define their differences, emphasize the importance of conducting backend […]
Roles and Responsibilities of Performance Tester
The core of efficient performance testing is an experienced, certified and well-structured team of professionals, who have already worked in similar projects, and learned all the peculiarities of QA testing types, and protocols. If consciously chosen, they can evaluate a product, test its behavior under a load, check its response time, etc., and thus, empower […]
Tips for Efficient Web Application Performance Testing
Performance testing is one of the most challenging components of web application testing. But it is worth it: if done right, performance testing can forecast product behavior and its response to user’s actions with an impressive amount of detail and precision. Irrelevant web performance test data or wrong metrics chosen during testing cost companies a lot of money and effort, while not monitoring your web application performance at all can lead directly to a crash, say, on Black Friday, if you are not prepared to handle an increased number of concurrent users. Business or product owners needn’t know exactly how to performance test a website, but it’s useful to have a basic understanding of procedures that you pay for. From this post, you can learn what web application performance testing is, when it should be done, and how. Then, you will be able to make an informed choice whether to hire testing specialists or run testing sessions on your own.
Be first to know
Once a month we’ll be sending you a letter with all the useful insights that we could find and analise
People love to read
Explore the most popular articles we’ve written so far
- Android vs iOS App Performance Testing: What’s the Difference? Dec 9, 2022
- How to Save Money on Performance Testing? Dec 5, 2022
- Performance Testing: What It Is, and Why You Need It Oct 7, 2021
- Cloud-based Application Testing: Features & Types Apr 15, 2020