JMeter Constant Throughput Timer is a goal-oriented element that helps achieve the desired throughput (Total Number of Requests). This timer maintains a constant throughput throughout the test and achieves 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 that you use a reasonable ramp-up time to avoid spikes (unless you’re doing some form of stress testing). There are some limitations associated with this element like
- Other timers may impact the 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 the transaction’s count from the aggregate report to check whether the 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 scenarios cannot be prepared using a constant throughput timer.
How to add a ‘Constant Throughput Timer’ in the JMeter script?
Follow the below steps:
- Select the appropriate element where you want to add the timer
- Test Plan
- Thread Group
- Controller
- Sampler
- Right-click on the element
- Hover the mouse on ‘Add’
- Hover the mouse on the ‘Timer’
- Click ‘Constant Throughput Timer’
What are the input fields of the ‘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 a 10,000 requests target in an hour then the target throughput value will be around 167 (=10000/60).
- Calculate Throughput based on: Choose an appropriate option as per the requirement. A description of the option is given below:
- this thread only: This option allows each thread to maintain its target throughput irrespective of group. The overall throughput will be proportional to the number of active threads. Let’s consider, if there are 5 users with 5 samplers and the target throughput value is set to 3 (samples per minute) 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:
- 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 option 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. However, 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 the target throughput value is set to 7 (samples per minute) then a total of 7 requests per minute will be sent combined. So, the triggered request after 1 minute will be 7.
- all active threads (shared): This option 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 a total of 5 users (Thread Group1 having 2 users and Thrad Group2 having 3 users) with 5 samplers each and the target throughput value is set to 8 (samples per minute) then total 8 requests per minute will be sent combined. So, the triggered request after 1 minute will be 8. Refer to the below screenshot:
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 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
You may be interested:
- Performance Testing Tutorial
- Performance Engineering Tutorial
- Micro Focus LoadRunner Tutorial
- NeoLoad Tutorial