0

Sometimes we execute JMeter script on production and it causes a load on servers

I don't want to stop the test, only reduce the load on server

How can I reduce threads number on runtime to avoid performance issues on server on load?

I saw similar question asked in the past with answers that say it cannot be done

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

If it can't be done, can/should I add timers that can add pauses on runtime?

EDIT I saw there's an open enhancement: Add ability to modify load while a test is running

I saw blazemeter blog post about using Beanshell server, but it seems an overhead for such rare cases

able to change the load generated by the performance test, without stopping the test. This can be done by using Apache JMeter™´s Constant Throughput Timer and the Beanshell server

Ori Marko
  • 56,308
  • 23
  • 131
  • 233

1 Answers1

0

Reducing number of threads currently can be implemented in 2 ways:

  1. Putting thread to "sleep" without actually stopping it, can be achieved using Flow Control Action Sampler

    enter image description here

  2. The same test element but for stopping the thread:

    enter image description here

In order to be able to run the sampler conditionally you can put it under the If Controller providing appropriate entry criteria

If you want to get the thread(s) back it can be done using JSR223 Test Elements invoking ThreadGroup.addNewThread() function

ctx.getThreadGroup().addNewThread(0, ctx.getEngine())
Dmitri T
  • 159,985
  • 5
  • 83
  • 133
  • But how I should communicate with the running test to enforce the sleep/stop? – Ori Marko Mar 04 '21 at 07:38
  • You mentioned the [Beanshell Server](https://jmeter.apache.org/usermanual/best-practices.html#beanshell_server). If it is not suitable for your needs you can also consider [Redis Dataset](https://www.blazemeter.com/blog/Using-Redis-Dataset-JMeter-Plugin) or [writing a custom plugin](https://jmeter.apache.org/usermanual/jmeter_tutorial.html) which will be listening for JMXRMI properties changes so you will be able to control the load via [JConsole](https://docs.oracle.com/javase/7/docs/technotes/guides/management/jconsole.html) or similar software – Dmitri T Mar 04 '21 at 07:46