Guide to JMeter Thread Groups

Guide to JMeter Thread Groups

This document describes different types of JMeter thread groups and their usage. When talking about performance testing, a very important factor is to try to simulate the actual user behavior as best as possible. In JMeter, Virtual user groups are represented by Thread Groups.

A Thread Group is a set of threads executing the same scenario. It is the base element for every JMeter test plan.

There are multiple thread groups available which can be configured to simulate how the users interact with the application, how the load is maintained and over what period of time.

Let’s explore each type of thread group in detail.

Thread Group

This Thread group is the most basic thread group. It has some standard settings and it can be adapted to fit most load test scenarios.

Let’s explore the Thread Group options:

  • Number Of Threads: It represents the total number of virtual users performing the test script execution.
  • Ramp-Up Period (in seconds): It tells JMeter how long to take to reach the full number of threads. For example, if you have 100 users with a ramp-up period of 50 seconds, JMeter will take 50 seconds to get all 100 threads running, adding 2 threads per second.
  • Loop Count: It is the number of executions for the script. For example, if the loop count is 2 and number of threads is 100 then the script will run 200 times. If the loop count is set “forever” then new threads will keep starting until the tests are stopped.
  • Delay Thread Creation Until Needed: If this option is checked, the ramp-up delay and startup delay are performed before the thread data is created. If not checked, all the data required for the threads is created before starting the execution of a test.
  • Scheduler: This schedules the tests. You can set custom duration and startup delay to create the threads in this section.

Arrivals Thread Group

Arrival is the start of thread iteration.

Thread Group Configuration options:

  • Target Rate: Used to define the number of new arrivals per minute.
  • Ramp-up Time: This tells JMeter how long to take to reach target arrival rate.
  • Ramp-up Steps: It refers to the granularity of the arrivals increased rate. More steps results in a smoother pattern.
  • Hold Target Rate Time: The duration which you want to run the tests for.
  • Thread Iteration Limit: This limits the number of iterations.
  • Concurrency Limit: This limits the number of threads.

Explanation for total number of arrivals:

Let’s break our test into 3 parts:

  1. 0-30 seconds
  2. 30-60 seconds
  3. 60-180 seconds

Totals Arrivals = Arrivals between 0-30 sec + Arrivals between 30-60 sec + Arrivals between 60-180 sec

Now in the test plan, ramp up steps 2 and ramp up rate is 1 minute. That means 120 arrivals per minute is reached in 1 minute with 2 steps (30 seconds each). So for the first 30 seconds arrival rate would be 60 arrivals per minute and number of arrivals for 30 seconds @60 arrivals per minute is 30 (as its running for 30 seconds).

For 30-60 seconds, the arrival rate is 120 and number of arrivals for 30 seconds @120 arrivals per minute is 60 (120*30/60=60) arrivals.

For 60-180 seconds the arrival rate is 120 arrivals per minute so for 2 minutes the total arrivals is 120*2=240 arrivals.

So total number of arrivals = 30+60+240 = 330

This thread group is suitable for goal oriented scenarios. For example, if you want to see how your e-commerce application behaves when 50 orders are placed every second.

Concurrency Thread Group

This Thread group is also suitable for goal oriented scenarios, but the goal here is to have control over the number of concurrent users over a period of time.

Thread Group Configuration options:

  • Target Concurrency: The number of concurrent users which should be maintained after the ramp up.
  • Ramp Up Time: Timeframe required to reach target concurrency rate.
  • Ramp Up Steps: It refers to the granularity of the concurrency increase rate.  More steps results in smoother pattern.  Setting this field to 0 means that the ramp up will be smooth, and threads will have a uniform delay between them.
  • Hold Target Rate Time: The duration to maintain the target concurrency before starting to gradually shut down all threads.
  • Thread Iterations Limit: Limits the number of iterations.

Explanation for above configuration:

Every 1 minute, 20 users will be added until we reach 100 users. (5 minutes divided by 5 steps equals 1 minute per step. 100 users divided by 5 steps equals 20 users per step. Totaling 20 users every 1 minute).  After reaching 100 threads, all of them will continue running and hitting the server together for 5 minutes

Freeform Arrivals Thread Group

It is similar to arrivals thread group, the difference is that this thread group does not have ramp up time and steps options.

 

Thread Group Configuration options:

  • The Start and End Values: Start value means arrival rate at the beginning of the time frame (duration) and end value means arrival rate at the end of the time frame (duration).

In the above example, start value is 30 and end value is 60 and duration is 60 seconds.  That means JMeter will start with 30 arrivals per second at the beginning of the timeframe and it keeps on adding 1 arrival for every 2 seconds so as to reach target of 60 arrivals per second by the end of 60 seconds.

The total number of arrivals will be arrivals at 1st second + arrivals at 2nd second + … arrivals at 60th second.

In this case arrivals rate for the first 2 seconds is 30, and it will add one arrival rate for every 2 seconds so for the next 2 seconds (3rd and 4th second) the arrival rate is 31, the arrival rate for the next 2 seconds is 33…

Adding up all the arrival rates from 1st to 60th second gives total number of arrivals=30+30+31+31+32+32+….+60 ~= 2700.

  • The Duration:  The equivalent of the hold target rate from the previous thread group.
  • Thread Iteration Limit: The same as for the Arrivals Thread Group.
  • Concurrency Limit: The same as for the Arrivals Thread Group.

Stepping Thread Group

This is an older version of the Concurrency Thread Group and requires a bit more configuration.  Basically, the end result is the same, the only thing which is changed is the ramp-up and ramp-down.

The fields are pretty self explanatory and filling the input fields is like completing an incomplete sentence: This group will start xx threads (the aimed concurrency). First wait for xx seconds, then start xx threads, next add xx threads every xx seconds using a xx second ramp-up.  Then hold load for xx seconds (the hold rate time equivalent).  Finally, stop xx threads every xx seconds.

In any case, for scenarios where you have to maintain a certain number of concurrent users over a period of time, I suggest using the Concurrency Thread Group since you don’t have to bother with much configuration.

Ultimate Thread Group

The ultimate thread group is highly customizable and unlike the arrivals, or freeform and concurrency thread groups, this one kills the active threads after the set time has expired.  This would translate into real user behavior as the users close the application tab or browser.  This also means that the preview graph showing the expected parallel users will be really accurate since the ramp-down is controlled by the thread group, not determined by the execution time of each thread.  The thread group also fires up a new thread to maintain the thread count in the situation where one thread has finished executing.  See an example for this below:

Thread Group Configuration options:

  • The threads schedule table: You can add multiple rows, each of them being executed sequentially, each of them being started according to the ‘Initial Delay’ setting.  This means that the rows (virtual users groups) will be executed in parallel if the ‘Initial Delay’ setting is the same for all fields.
  • The start threads count field: You set the target thread concurrency.
  • The initial delay: Set how much time you wait before starting to execute the threads from that specific row.
  • The startup time: The ramp up time for all the threads set in the thread count. For example, for 20 threads and a start time of 20 seconds, you would have 1 new thread firing up every 1 second.
  • The hold load for field: This is where you set the duration to maintain the defined number of concurrent users and is totally independent from the ramp-up time.
  • The shutdown time:  The time interval for killing all the active threads.

All types of thread groups have a common option “Action to be taken after sample error”, used to specify what action to perform when an error occurs.  It can be Continue , Start Next Thread Group, Stop Thread, Stop Test, Stop Test Now.

Using Thread Groups

With RedLine13, you can run a JMeter Load Test with your JMX script of any mobile application, web application, or API.

Example Results:

With RedLine13, you can run a JMeter Load Test with your JMX script of any mobile application, web application, or API.

Run your own test on RedLine13.