Get Knowledge from Video instead of Content:

Monday 30 January 2017

JMeter - Timer - "Constant Throughput Timer"

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.
How to add "Constant Throughput Timer" element?
You can follow the below steps:
1. Select "Test Plan" or "Thread Group" or "Controller" or "Sampler" node where you want to add the timer
2. Right-click on the node
3. Mouse hovers "Add"
4. Mouse hovers "Timer"
5. Click "Constant Throughput Timer"

How to remove "Constant Throughput Timer" element?
You can follow the below steps:
1. Select "Constant Throughput Timer" node
2. Right click on "Constant Throughput Timer" node
3. Click "Remove" (Mouse) or "Delete" button from the keyboard
4. Click "Yes"    



What are the attributes of "Constant Throughput Timer" element?
"Constant Throughput Timer" has following attributes:
  • 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: 
  • 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:

  • 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.

  • 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:

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 throughput value:
  • Using a counter variable
  • Using a JavaScript or BeanShell function to provide a changing value
  • Using the remote BeanShell server to change a JMeter property
Next Topic:
Apache JMeter - "Throughput Shaping Timer" Element

Previous Topic:
Apache JMeter - "BeanShell Timer" Element

Related Topics:

6 comments :

  1. Nice explanation. Could you please clear my doubt over below points?
    1. What is difference between "all active threads" and "all active threads (shared)".
    2. What is difference between "all active threads in current thread group" and "all active threads in current thread group (shared)".

    ReplyDelete
    Replies
    1. Hi Karan,

      It is already explained above. Request you to do practical (of given example) for clear understanding.

      Delete