How to implement pacing in Jmeter using different timers

What is Pacing?

Pacing in load testing refers to the time between the iterations of your test scenarios. This is unlike Think Time, which refers to the delay between actions or interactions inside iterations.By using pacing in your test, you will be able to regulate the rate of requests that hit your application and accurately achieve a desired load. This will allow you find out the exact load capacity your application can handle.Pacing allows the load test to better simulate the time gap between two sessions. In reality, the same user will not instantaneously go to the next iteration, so this wait time between sessions will create a more realistic load on your application.

Below timers are used to implement pacing in Jmeter to achieve the desired load/Business transactions.

1.Precise Throughput Timer

2.Constant Throughput Timer

3.Throughput Shaping Timer

Lets consider below load scenario for example:

Total no of users = 5

Total no of transactions = 40 (100 requests)

Duration = 5m i.e 300s

Note: A transaction may have more than one requests 

Every transaction have more than one requests in that case we have to calculate pacing on the basis of total of requests in all the transactions but not on the basis of total transactions.In this post we will implement above scenario by using all 3 above timers.

Assuming that already we have a jmeter script:

For example ,we have below transactions in our script:

1.Google Search Request123 : which contains 3 requests -> Google Search Request1 ,2 & 3

2.Google Search Request45 : which contains 2 requests -> Google Search Request4 & 5

1.Precise Throughput Timer

The Precise Throughput Timer is a timer that enables users to determine the throughput (samplers per second/minute/hour/etc.) they want to run in their tests. Compared to the Constant Throughput Timer, the user is more flexible when deciding how to spread out the samples over time. In addition, execution is scheduled in a random way, enabling a constant load to build up. Finally, this timer uses the Poisson arrival schedule for its pauses, making it close to real-life scenarios.

Add a Precise Throughput Timer (Thread Group->Add->Timers->) .We have to achieve 100 requests by 5 users in 300 second. Setup the timers as per below setting:

a. Target throughout = 100

b.Throughput period (Seconds) = 300 (Total time to achieve the desired throughput).

c.Number of threads in the batch (threads)= 1

d.Use approximate throughput when sequence length exceeds (samples) = 100 (total no of requests)

e. Allowed throughput surplus (Percents) = 10

Run the test and see the results in View Results Tree. Test has achieved the expected load i.e 40 transactions.

2. Constant Throughput Timer:

A Constant Throughput Timer can pause the threads in order that a goal-oriented scenario could be implemented. Goal-oriented scenario is a load test type where the target is not to simulate X concurrent users, but X requests per second. A Constant Throughput Timer works precisely on the “minute” level, so make sure that your test lasts long enough.

Add a constant throughput timer (Thread Group->Add->Timers->) .We have to achieve 100 requests by 5 users ,1 users will execute 20 requests.

RPM (Request per minute) = total requests/ duration in minute = 100/5 = 20 request per minute per user .

Now we have to share this RPM among all users.Setup “Constant Throughput Timer” as per below setting:

a. Set “20” for “Target Throughput(in samples per minute)

b.Select option “all active threads in current thread groups(shared)” from the Calculate Throuput based on drop down.

Run the test and see the results in View Results Tree. Test has achieved the expected load i.e 40 transactions.

3. Throughput Shaping Timer:

It is used to control the amount of requests per second(RPS), we are essentially spacing out the iterations of the test, allowing for rest periods between iterations of the scenario.you have the plugin installed using either the Plugin Manager, or by downloading the JAR and inserting it into the /lib/ext folder within your JMeter folder.

Add a Throughput Shaping Timer (Thread Group->Add->Timers->) .We have to achieve 100 requests by 5 users ,1 users will execute 20 requests.

RPS (Request per second)= total requests/ duration in minute = 100/5*60 = 0.333 i.e 0.35 request per second per user .for 2 users RPS = 0.70 rps.

Setup the timers as per below setting:

a. add the Row

b. set 0.70 for Start RPS and End RPS , set 300s for Duration.

Run the test and see the results in View Results Tree. Test has achieved the expected load i.e 40 transactions.