In previous post I went through JMeter’s constant throughput timer (CTT) component usage and behaviour. Now, building on that knowledge I’ll show you some tips on how to make your life easier when using CTT.

Defining throughput variables in a separate component

We’ll  start with a basic configuration step that we will heavily rely on down the road.
Let’s define all of the default throughput figures in a single place e.g. in a “User Defined Variables” component. Additionally, we will utilize JMeter’s read property function ${__P()}, to enable us working in more flexible way with CTT.



Apart from having a clear view on all of the throughput figures in one place, this configuration makes possible reading them from external properties files. We might use files with different throughput values in other tests to check behaviour of the system under different workloads.

Introducing throughput modifier

Next up, let’s introduce a very useful change – adding a variable that I call throughput modifier.
Definition of the variable:



Now, we can use it in each of the CTT components in the script.  We will multiply values of modifier and target throughput, surrounding it also by jexl function to execute the operation, e.g.:





Thanks to this simple trick you’ll be able to change the level of load that you want to achieve during a test, using just a single variable.


For instance, in one test you might want to go with the default target throughput and set the modifier to 1. In another, if you might want to add 30% more load, all you need to do is just set the modifier to 1.3 and you’re ready to go. Simple, right?

Adding ramp-up capability

The throughput modifier also enables an implementation of another useful feature which is a ramping up/down on throughput.

You can use it to:
  • slowly ramp up the load to the default target value
  • ramp it beyond the target, e.g. when doing stress testing
  • ramp down the load if needed
How to do it? Let’s look at some code for the ramp-up simulation:


// definition of how the ramp-up should look like
// e.g. starting with 10% of the target throughput, finishing at 100% (full target throughput), while doing 1% steps
float start = 0.1;
float end = 1;
float step = 0.01;
// computing how much time to spend (sleep) on each step
float numberOfSleeps = (end - start) / step;
int sleepDuration = rampUpDuration / (numberOfSleeps);
// setting the throughput modifier property during the execution of the script, it will be picked up by CTT components
// the correct interval between load increases is enforced by the sleep
for (float i = start; i <= end; i = i + step) {
    props.put("ThroughputModifier", i.toString());
    Thread.sleep(sleepDuration * 1000);

OK, but where do you need to put the code in JMeter to be actually able to use this stuff?

I usually place the code in a separate thread group in either of:

  • BeanShell/JSR223 sampler


  • BeanShell/JSR223 pre-processor put as a child of a Test Action sampler

The thread group only fires up a single thread, that does one iteration of this code. And that’s it.


However, I always tend to add a bit of additional parameterization, to be able to set some of the variables from outside of the script. Let’s have a look at some more code, this time containing a few of props.get() methods :

// checking if I actually want to use this feature
if (props.get("UseThroughputRampUp").equals("Y")) {

    int rampUpDuration = Integer.valueOf(props.get("ThroughputRampUpPeriod"));
    // Restricting ramp up duration (execution time of throughput ramp up thread group) to test duration
    if (rampUpDuration > Integer.valueOf(props.get("testDuration"))) {
        rampUpDuration = Integer.valueOf(props.get("testDuration"));

    float start = Float.valueOf(props.get("ThroughputStartingValue"));
    float end = Float.valueOf(props.get("ThroughputLimit"));
    float step = Float.valueOf(props.get("ThroughputStep"));

    if ((end - start) > 0) {
        float numberOfSleeps = (end - start) / step;

        int sleepDuration = rampUpDuration / (numberOfSleeps + 1) * 1000; // computation and conversion to miliseconds

        for (float i = start; i <= end; i = i + step) {

            props.put("ThroughputModifier", i.toString());
    } else {
        log.warn("Throughput ramp up will not be executed. Throughput limit should be greater than starting value of throughput);

Other stuff worth mentioning pertaining JMeter’s throughput topic

When considering driving load with throughput in JMeter, you may also want to familiarise yourself with two other subjects:
  • JMeter plugins component called throughput shaping timer
  • Beanshell server

I will go back and cover them in some future posts.