Using the JMeter Throughput Shaping Timer Plugin

Using the JMeter Throughput Shaping Timer Plugin

Imagine you have a task to test the throughput of a system at a specified Requests Per Second (RPS) rate. To achieve the desired rate using regular thread groups you would need to play around with the number of threads and timers. This is not an efficient way to generate load. You can simply use JMeter’s Throughput Shaping Timer Plugin.

The Throughput Shaping Timer plugin allows you to load test the RPS more effectively. It is designed to schedule RPS load. You can click here to download the Throughput Shaping Timer. First, download the jar file and place it in lib/ext folder of JMeter and then restart JMeter to apply the changes.

Throughput Shaping Timer Properties

The Throughput Shaping Timer element is a timer that sets the desired RPS schedule via the JMeter GUI. It exposes the following component properties that contain information about the duration and current state of the test where elementName will be the name of your timer.

  • elementName_totalDuration – Total duration as sum of the “Duration,sec” column.
  • elementName_cntDelayed – Number of current threads waiting. If less than 1, it means we don’t have enough threads to reach the RPS.
  • elementName_cntSent – Number of samples sent since last second tick.
  • elementName_rps – Current RPS.

You can access these properties through the __P function.

Special Property Processing

You can specify the load pattern using a special JMeter property called load_profile. The property can be specified either in the user.properties file (JMeter.properties also applicable) or from the command line like -J "load_profile=...". The load pattern is specified with a set of function-like declarations. “Functions” may be of 3 types: const, line and step.

  • const(N, T) – Hold constant load of N requests per second for T seconds.
  • line(N, K, T) – Linear increase load from N to K RPS during T seconds.
  • step(N, K, S, T) – Generate stepping load from N RPS to K RPS. Each step height to will be of S RPS and each step duration will be T seconds.

The duration value in every function may be specified with shorthand case-insensitive modifiers:

  • s = seconds
  • m = minutes
  • h = hours
  • d = days

An example load profile string might look like this:

load_profile=const(10,10s) line(10,100,1m) step(5,25,5,1h)

A Schedule Feedback Function

The Schedule Feedback Function is a function that allows dynamic changes to the thread number to meet the RPS schedule. A Thread Group can use that function to supply additional threads during the test runs to meet requested RPS schedule.

Here is an example function call:

${__tstFeedback(tst-name,1,100,10)}

Here, tst-name is the name of Throughput Shaping Timer to integrate with, 1 and 100 are starting threads and max allowed threads, and 10 is how many spare threads to keep in thread pool. If spare threads parameter is a float value less than 1, then it is interpreted as a ratio relative to the current estimate of threads needed. If greater than 1, spare threads is interpreted as an absolute count.

How Many Threads Should You Run?

Here is the formula to calculate thread pool size:

Thread Pool Size = RPS * <Max Response Time>/1000

It is better to have some thread overhead to handle unexpected response time spikes, but beware of too much overhead, as it will lead to “final spike”.

Running a JMeter Load Test

You can download sample JMX from here and run a JMeter load test. Here’s some more info on Running a JMeter Load Test.

You can also get advanced analytics in real time and you can share the reports with your team. You can see sample reports here..

Load test example data 1

Load test example data 2