A standard JMeter Performance script contains test scenarios organized under separate logic controllers. These controllers let you define the order of user request to execute. There are many types of logic controllers for different purpose. It is very likely that you need to build your JMeter test plan to distribute the specific load for each business critical test scenarios. In this article, we are going to discuss about Throughput Controller. It allows you to setup user load distribution to create production like behavior when doing load testing.

What is User Load Distribution?

Let’s take an example of Hotel Booking application. Each hotel booking website has below mentioned features:

1) Hotel Search
2) New User Registration
3) User Login & Compare Hotels
4) User Login & Book Hotel
5) Cancel Booking
6) Admin Users


Our requirement is to test above test scenarios with 1000 concurrent users. Now we know that no users who search for hotels are going to complete the booking process. Some of them will just focus on comparing the price and services of hotels. Few of them will go ahead and complete the booking process while there will be some who will cancel the booking. Google Analytics is the best tool to identify the frequency of users visiting pages of application. By thoroughly studying this information we can derive statistics and with the confirmation of concerned person like Product Owner, BA, Project Manager we can identify the load to put on each scenario. This distribution can be something like this:

1) Hotel Search (40% User Load)
2) New User Registration (10% User Load)
3) User Login & Compare Hotels (20% User Load)
4) User Login & Book Hotel (20% User Load)
5) Cancel Booking (10% User Load)

To achieve such behavior there are 2 options available in Apache JMeter: 1) User separate Thread Group for Each Scenario 2) Throughput Controller.

Separate Thread Group for Each Scenario with Different Number of Threads

This is the most easiest way to implement the distributed Load on each feature. Each Thread Group can have set of HTTP Requests belong to specific group or feature. In above example, we will need 5 Thread Groups each having different amount of user load. Thread Group 1 – Hotel Search will have thread count as 400 users, Thread Group 2 – New User Registration will have 100 Users, Thread Group 3 – User Login & Compare Hotels will have 200 Users, Thread Group 4 – User Login & Book Hotel will have 200 Users & Thread Group 5 – Cancel Booking will have load of 100 Users.

Throughput Controller

Note: Please make sure that checkbox “Run Thread Groups Consecutively” is unchecked to generate concurrent user load.

Throughput Controller

Once we run this Test Plan, each Thread Group will have the exact amount of User Load as per the distribution. This kind of setup is easy to have when our test script is not much complicated and it is manageable to have separate Thread Group for each scenario. What if you can not have separate Thread Group for your load test scenarios? Seems like, here is the perfect and simple solution for that:

Throughput Controller

Before we go into understanding this controller let’s clear the confusion of it’s name which can be misleading. This controller does not control the Throughput, hence if you are looking for something to manage your Throughout then you need to check this out: Constant Throughput Timer.

Primary objective of Throughput Controller is to define and control the User Load for each group separately under same Thread Group. Let’s see how you can add the Throughput Controller.

How to Add Throughput Controller

Right Click on Thread Group > Add > Logic Controller > Throughput Controller.

Throughput Controller

Throughput Controller has 2 options: Total Executions, Percent Executions.

1) Total Executions: All child requests placed under this controller will be executed as per defined number. The thread creation will stop after the defined number of execution have occurred.

– Per User Checked: The number given for throughput will be the total number of executions for current controller.
– Per User Unchecked: Total number of Threads(Users) given under Thread Group will be the total number of executions for current controller.

Now let’s look at some examples:

Example 1:

– Thread Group (100 Threads)
– Throughput Controller 1 (70 Throughput)
– Throughput Controller 2 (30 Throughput)
– Per User unchecked

As shown in the screenshot, sample request 1 from first controller executed 70 times and from sample request 2 executed 30 times.

Example 2:

– Thread Group (100 Threads)
– Throughput Controller 1 (10 Throughput)
– Throughput Controller 2 (20 Throughput)
– Per User unchecked

As shown in the screenshot, sample request 1 from first controller executed 10 times and from sample request 2 executed 20 times.

Example 3:

– Thread Group (100 Threads)
– Throughput Controller 1 (10 Throughput)
– Throughput Controller 2 (20 Throughput)
– Per User checked

As shown in the screenshot, sample request 1 from first controller executed 100 times and from sample request 2 executed 100 times.

2) Percent Executions: All child requests placed under this controller will be executed according to the percentage defined under Throughput field. Most importantly, this percentage will be calculated separately for each controller based on the amount of user load defined under Thread Group. Let’s take an example of Test Plan with 100 concurrent users.

Example:

– Thread Group (100 Threads)
– Throughout Controller 1 (10%),  Throughout Controller 2 (20%),  Throughout Controller 3 (30%),  Throughout Controller 4 (40%)

As shown in the screenshot, sample requests from each controllers is executed as per the % throughput defined for that controller.

Conclusion:

Throughput Controller is used to distribute the User load within single Thread Group hence it becomes one of the most crucial and must have element of Test Plan. Furthermore, it allows you to setup the user load for various complex conditions. As a result, we can build the Test Plan to meet the Production like behavior.

Hope you find this article helpful and knowledge worthy. Please leave a comment to provide a feedback. Happy Testing!!


Share This Article :