'JMeter: request second endpoint at specific time?

I would like to simulate a scenario where many users of a website complete two tasks:

  1. request a first endpoint at a random time within a 5-minute interval.
  2. request a second endpoint at a specific time.

This is to simulate a situation where lots (thousands) of users are logging in at staggered times, but then all requesting a specific resource at the same exact time.

I've been reading about JMeter Scheduler but it doesn't look like it can schedule successive tasks within the same thread group as far as I can tell.

Is this possible in JMeter? If so, how? And if not, what alternative testing situation would you recommend? Headless Selenium? An alternative headless browsing environment? I need the tests to generate a user's browsing session per thread.



Solution 1:[1]

One of the ways is to use Timers. The whole setup would look like this:

enter image description here

In the first step, you can use one of the timers that randomize the start of the request, for example I used Uniform Random Timer. Since you want your users to run first request random time within a 5-minute interval, you can configure it so that it runs with max delay of 5 min = 300000 ms / number of users. So for 100 users the configuration is:

enter image description here

The most obvious option for second step is Synchronizing Timer:

enter image description here

Although it's not at a specific time, but it's when multiple threads wait for each other, and then do something at once. So you achieve your overall goal where "all requesting a specific resource at the same exact time".

Controllers are needed in both cases to control the scope of timers (we only want timers applied to corresponding request.

That will work for multiple iterations too, unlike Ramp-up / schedule, which only matters for the start of the test.

If you really have to start second step at specific times, you can use BeanShell Timer to program that.

Of course there are other entirely different (and more complicated) options. For example trigger requests at specific times by running JMeter test from Java code. But hopefully simple solution is sufficient.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ohglstr