Over a million developers have joined DZone.

Advanced Load Testing Scenarios With JMeter (Part 3): Top 4 Timers

DZone's Guide to

Advanced Load Testing Scenarios With JMeter (Part 3): Top 4 Timers

In part three of this series, see which four timers work well with JMeter for better control during your load testing.

· Performance Zone
Free Resource

Evolve your approach to Application Performance Monitoring by adopting five best practices that are outlined and explored in this e-book, brought to you in partnership with BMC.

Welcome to part three of the “Advanced Load Testing with JMeter” series. If you missed part two, which explained Data-Driven Testing and Assertions, check it out here.

In this part, we will go over the top four recommended Timers, as they are the most useful for common testing needs . Timers enable us to incorporate the natural delays users make into our tests.

JMeter offers many different timers. In this blog post we will go over the four types we recommend. For a more comprehensive list and explanations, see here.

To see the full JMeter Timer List, click on the Thread Group -> Add -> Timer.

timers list on jmeter

1. The Uniform Random Timer

We highly recommend using the Uniform Random Timer. This is also the timer the BlazeMeter chrome extension recorder adds. Its main advantage is that it can simulate different delay lengths. This helps simulate realistic user behaviour on the web page.

uniform random timer on jmeter

The Uniform Random Timer enables you to insert two parameters:

1. A constant delay that will always occur.

2. A random delay that occurs randomly.

Together the two parameters create a range of optional pauses that JMeter will incorporate into the test. In this example, the threads will pause anywhere between ~9 seconds to ~14 seconds before the request it’s placed under is sent.

While each sampler has its own Uniform Random Timer, you can turn them all off:

uniform random timer, thread group, jmeter

After turning them off, you can move the one you want above the thread group. Its parameters will now run for each sampler. A timer will be executed before all the requests in the scope it’s in.

uniform random timer, thread group, jmeter

2. The Constant Timer

The Constant Timer also simulates delays between requests, but it’s used for adding a permanent delay as opposed to a randomized delay.

In this example, the constant delay added is 300 milliseconds long.

constant timer on jmeter

This timer will apply to every single request. If requests include additional timers, the delays will add up.

3. The Constant Throughput Timer

The Constant Throughput Timer doesn’t measure user delays but rather limits the requests per second by adding delays between the requests. This timer enables you to see what the server does and how it functions under a specific request-per-second rate, which is another important way to discover bottlenecks.

constant throughput timer on jmeter

(Note that we have to adapt from requests per second to requests per minute).

This timer can also be modified on the fly, so if you monitor your test in real time and you notice that the server is handling X requests per second, then you can increase it to X+100 and see how it endures under the new hit rate. For detailed explanations on modifying the Constant Throughput timer on the fly, please refer to this article.

This timer can be applied for various threads configuration:

constant throughput timer threads configuration on jmeter

To view Throughput more accurately we need to add the Aggregate Listener.

aggregate listener on jmeter

aggregate report on jmeter

Now run the test. It might take some time to get to its target.

4. The Synchronizing Timer

The Synchronizing Timer stops all threads when hitting the tested Number of Virtual Users, and then has them all perform the same action at once. This Timer is useful for extra stress testing. In this example, we will test 20 users simultaneously purchasing a flight ticket.

synchronizing timer on jmeter

Add the ‘View Results in Table’ Listener. See how all the flight purchasing is occurring at approximately the same millisecond:

view results in table listener, jmeter

Congratulations! You are now ready to use Timers. Stay tuned for next time, for our final blog post in this series.

Learn tips and best practices for optimizing your capacity management strategy with the Market Guide for Capacity Management, brought to you in partnership with BMC.

load ,advanced ,testing ,jmeter ,timer ,throughput

Published at DZone with permission of Noga Cohen, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.


Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.


{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}