JMeter – Precise Throughput Timer

JMeter Precise Throughput Timer is a goal-oriented element that helps to achieve the desired throughput (Total Number of Requests per unit of time). This timer maintains the throughput throughout the test and achieves the target. Of course, if the server is unable to handle such a load, the throughput will be lower. Throughput may decrease if other timers contradict the Precise Throughput timer. Hence avoid the use of other timers along with the Precise 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 the Precise Throughput Timer is best for such scenarios. A Precise 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 gracefully. Once the test duration ends then all the threads stop; even though they are in the middle of the iteration.
  • The timer does not generate threads. 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 precise throughput timer.
JMeter - Precise Throughput Timer
Figure 01

How to add a ‘Precise Throughput Timer’ in the 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 the ‘Timer’
  5. Click ‘Precise Throughput Timer’ (The recommended place to add the Precise Throughput Timer is under the Thread Group inside the Debug Sampler)

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

  • Name: To provide the name of the timer
  • Comments: To provide arbitrary comments (if any)
  • Target throughput (in samples per throughput period): The number of samples sent by JMeter to achieve the throughput in the provided throughput period. It includes all thread groups and affected samplers. 
  • Throughput Period (seconds): The time duration in which the defined number of requests has to be sent. Example: If the throughput period is 100 seconds and the target throughput is set to 150 then you’ll get the throughput rate as 3 samples per second.
  • Test duration (seconds): This is used to ensure you’ll get throughput*duration samples during the “test duration” timeframe.
  • Number of threads in the batch (threads): The recommended value is 1. If you want to achieve a simultaneous behaviour of the threads then provide the desired value. Example: If you set the value as 5 then 5 threads depart from the timer simultaneously. The average throughput still meets the “throughput” value.
  • Delay between threads in the batch (ms)To maintain the concurrency of the thread, you can add the delay. For example, if the value is set to 1000 and the batch size is 5 then threads will depart at x, x+1000ms, x+2000ms, x+3000ms, x+4000ms.
  • Random seed (change from 0 to random): Constant seed ensures the timer generates the same delays each test starts. The value of “0” means the timer is truly random (non-repeatable from one execution to another).

Example:

Let’s consider, a business requirement to test an application with 2 TPS i.e. 2*3600 = 7200 requests per hour. The client needs the test to run for 15 minutes. Below is the list of cases run with different settings for the same requirement.

CaseThreadDuration (seconds)Target ThroughputThroughput PeriodTest DurationExpectedActual
11090072003600360018001793
2109007200360030018001801
310900180090090018001801
410900600300360018001793
JMeter – Precise Throughput Timer
Figure 02: Case 1
JMeter – Precise Throughput Timer
Figure 03: Case 2
JMeter – Precise Throughput Timer
Figure 04: Case 3
Figure 05: Case 4

Case 2 and Case 3 precise the throughput and met the requirement. The conclusion is to keep the test duration of the Precise Throughput Timer less than or equal to the actual Duration (under Thread Group). However, the actual throughput count also depends on multiple factors like Thread Count, Ramp-up, other Timers, Response Time, Network latency etc.

Additional Information:

  • Although the Timer is called the Precise Throughput timer, it does not aim to produce precisely the same number of samples over one-second intervals during the test. The timer works best for rates under X requests/hour however your actual count of samplers might vary.
  • It is recommended that the value be set as 0 for both the ramp-up period and delay while using a precise throughput timer.

You may be interested: