Change the number of threads in a test plan in JMeter at run time

I want to change the number of threads for a JMeter test plan at runtime.

I have a problem with Google and found a suggested solution for using JMeter plugins. But in this solution, I would have to plan a group of threads before starting a test plan, which I don’t want. I also found another potential solution that modifies the property, but does not affect the behavior of the test plan at runtime.

Ultimately, what I'm trying to do is change the thread number given in the thread group and immediately increase or decrease the number of threads in the current test plan.

Is it possible?

+8
java jmeter load-testing
source share
6 answers

Short answer: no, you cannot dynamically change the number of threads at runtime. Each value of the thread counter is read only once, when the test plan is first compiled and after this point is not resolved again, so it remains fixed.

+3
source share

IMHO is just a fancy feature that does not have real benefit with proper performance testing. To create an appropriate test result (report), you need repeatability , as well as a well-defined testing methodology and scripts. To compare the impact of any application / server / infrastructure changes, you need repeatability.

What do you mean by

We cannot predict the user of our site.

This is why we conduct performance testing in the first place. To find out what our application / infrastructure limit is.
That is, the most significant metric that you can produce is how the response time of your application changes when the number of concurrent users changes. But do not modify with errors at runtime.

With jMeter plugins' Ultimate thread group, you can cover any imaginable scenario.

+6
source share

This feature is really useful and surprisingly hard to implement even with commercial tools like Loadrunner. I would compare it to finding the speaker volume. You will manually increase the volume until it starts to crack, and then turn it slightly to maintain maximum volume. Similarly, to find the maximum capacity of the application, you want the control to “increase the volume” until errors are visible, and then release it slightly to see if it is stabilizing. You can then support this load to find a bottleneck spot.

In any case, to answer the question, what have I done in the past is the use of external influence, such as a file name or the like. Then combine this with a unique thread reference, you can control which threads are running and which are being held (by pause or similar).

For example, if you start with 100 threads, then create a file called "5.txt" in a specific place, you can add the code so that the streams see that its own link is equal to or less than the number, then it can work. If not, it goes into a pause. At the beginning of this example, 5 threads will execute, and 95 will pause. Then you can rename the file to '25 .txt ', and streams 6 through 25 will start working. This would work the other way around, changing it to "20.txt" would mean that threads 21-25 are again paused.

The key is to run enough threads to exceed the expected peak.

+2
source share

you can change it based on the variable set in the startup thread. See below.

In Jmeter, how to set a variable number of threads using the beanshell selector variable?

However, once a thread group is started, you cannot change it. To the guy who said that this feature will not be useful, I do not agree. There are many types of stress tests, and they do not all have the same number of time users. Here are just two examples of the types of enterprise load tests that we conduct in the bank where I work:

  • Test duration - the same number of users starts all the time (possibly with a short rise period)
  • Breakpoint Test - Increases the number of users step by step until application breaks
  • Spike test - works with a constant number of users, but sporadically - drop a large number of users

The breakpoint test increases the number of users until the application breaks (point of view on how high your application can scale). You can do this using the group property "Rise Time Period". If you set the rise time to 1000 and the number of threads to 100, it will add 1 thread every 10 seconds.

Spike tests are similar to duration tests, but a large number of users are registered at regular intervals. This is used to determine application response time during peak hours or how it will respond if you suddenly get a large number of users (a very real scenario).

I found that Jmeter does not handle all the load scenarios that are needed to test the load in enterprises. One work around Im is just to start all the topics, but find a way to make some of them sleep. Thus, you can set the number of threads to 1000, but somehow make 980 of them sleep or do nothing. Then, perhaps, when time_in_seconds% 5 == 0 (every 5 minutes) you allow other threads to run - simulating a spike test. The idea is that you can hard code the streams up to 1000 and you will always have 1000 streams, but not all of them should do anything at any time.

(in other words, you can probably find a way, but you need to create a creative approach)

Update: I just found this plugin that allows for various types of testing. I have not tried it yet, but it looks promising: http://jmeter-plugins.org/wiki/ThroughputShapingTimer/

+1
source share

You can set / change the number of threads at runtime using the command line option ...

you can use function calls or variable references to User Parameters (which, in turn, can be functions), or variable references to variables set earlier in the test. There is more than one way to do this.

Suppose you want to be able to change the number of threads in a test plan. Choose the appropriate property name, for example group1.threads. Replace the number of threads in the GUI (or JMX if you feel brave!) With the following function call:

Specify the property below in the JMeter thread group, as shown below. $ {__ property (group1.threads)}

Then, when starting JMeter, define the property on the command line:

jmeter -Jgroup1.threads = 10

0
source share

We cannot predict the user of our site.

Of course. This is what is for the HTTP logs of your existing site. You can also use magazines from tools such as Omniture or CDN magazines. If you look at the combination of the user's actual IP addresses, request tags, and referrers in the logs, you can build a single-user bypass map on your site. You will be able to profile unique node leaf pages with a unique leaf of a given business process to understand how many times each particular business process occurs in an hour. You can study failure by looking at the funnel in tools like Omniture. If you need tools for this analysis, I recommend Splunk. It is easy to install and configure. Time to evaluate is very fast.

The more log data you use for profiling, the closer you can do what users do during the day / week / month / sales on the spot / end of the quarter / end of the year / etc .... You need to combine the actual data at a certain point time with actual from earlier points in time to predict growth over time, as you will need to ensure growth in your performance testing model.

If you do not get the value correctly, the value of your test as a predictor of what will / may happen in production will be quite low. This is not a failure of any given tool, but a failure on the planning front for the actual load model used as part of the test requirements. If you cannot build these models, you need to bring someone to your team who can.

This ability to create a valid load model is independent of the tool - this is the difference between tests that reduce risk and drop the load.

0
source share

All Articles