JMeter – Constant Throughput Timer

JMeter - Constant Throughput Timer

JMeter Constant Throughput Timer is used as a goal-oriented element which helps to achieve the desired throughput (Total Number of Requests). This timer tries to maintain a constant throughput throughout the test and achieve the target. Of course, if the server is not able to handle such a load, the throughput will be lower. Throughput may decrease if other timers contradict the Constant Throughput timer. Hence it is not recommended to use other timers along with the Constant Throughput Timer.

If you want to execute a Goal-oriented scenario where the target is not to simulate the number of concurrent users, but the number of requests per second then Constant Throughput Timer is best for such type of scenario. A Constant Throughput Timer works precisely on the “minute” level, so make sure that your test lasts long enough (1 minute or more) and you use a reasonable ramp-up time to avoid spikes (unless you’re doing some form of stress testing). There are some of the limitations associated with this element like

  • Other timers may impact constant throughput timer target, so it is recommended not to use other timers.
  • To get the exact sampler’s count at the end of the test, you need to eliminate transaction’s count from the aggregate report to check whether constant throughput timer is working fine or not.
  • The achieved target may be slightly high.
  • The threads are not stopped in a graceful manner. Once the test duration ends, then all the threads stopped; even though they are in the middle of the iteration.
  • You need to decide the number of threads wisely so that a real-time scenario can be prepared.
  • Step-up and Spike Test scenario cannot be prepared using constant throughput timer.
Figure 01

How to add ‘Constant Throughput Timer’ in JMeter script?

Follow the below steps:

  1. Select the appropriate element where you want to add the timer
    1. Test Plan
    2. Thread Group
    3. Controller
    4. Sampler
  2. Right-click on the element
  3. Hover the mouse on ‘Add’
  4. Hover the mouse on ‘Timer’
  5. Click ‘Constant Throughput Timer’

What are the input fields of ‘Constant Throughput Timer’?

  • Name: To provide the name of the timer
  • Comments: To provide arbitrary comments (if any)
  • Target throughput (in samples per minute): Number of requests that need to be triggered in a minute. If you need to achieve 10,000 requests target in an hour then target throughput value will be around 167 (=10000/60). 
  • Calculate Throughput based on: Choose an appropriate option as per the requirement. Description of the option is given below:
  • this thread only: This option allows each thread to maintain it’s own target throughput irrespective of group. The overall throughput will be proportional to the number of active threads. Let’s take an example: if there are 5 users with 5 samplers and target throughput value is set to 3 seconds then each thread will send 3 requests per minute separately. So, the triggered request after 1 minute will be 45 (=5 x 3). Each thread will send 3 requests per minute:
JMeter - Constant Throughput Timer
Figure 02
  • all active threads in current thread group: On selecting this option, the target throughput is divided amongst all the active threads in that particular group. Each thread will delay as needed, based on when it last ran. 
  • all active threads: This options divides the target throughput amongst all the active threads in all Thread Groups. Each thread will delay as needed, based on when it last ran. In this case, each other Thread Group will need a Constant Throughput timer with the same settings.
  • all active threads in current thread group (shared): On selecting this option, the target throughput is divided amongst all the active threads in that particular group, but each thread is delayed based on when any thread in the group last ran. Let’s try to understand with an example: if there are 5 users with 5 samplers and target throughput value is set to 7 seconds then total 7 requests per minute will be sent combinely. So, the triggered request after 1 minute will be 7.
JMeter - Constant Throughput Timer 01
Figure 03
  • all active threads (shared): This options divides the target throughput amongst all the active threads in all Thread Groups; each thread is delayed based on when any thread last ran. Let’s try to understand with an example: if there are 2 Thread groups with total 5 users (Thread Group1 having 2 users and Thrad Group2 having 3 users) with 5 samplers each and target throughput value is set to 8 seconds then total 8 requests per minute will be sent combinely. So, the triggered request after 1 minute will be 8. Refer below screenshot:
JMeter - Constant Throughput Timer
Figure 03

Additional Information:

Although the Timer is called the Constant Throughput timer, the throughput value does not need to be constant. This value can be changed during a test. Several options that can be used to change the throughput value through:

  • a counter variable
  • a JavaScript or BeanShell function to provide a changing value
  • the remote BeanShell server to change a JMeter property

Leave a Reply

Your email address will not be published. Required fields are marked *