Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JMeter - Firing different requests in every iteration

I am currently using JMeter to simulate 5 users firing requests every 40 seconds. I have created 100 different requests but after every 40 seconds, each user is firing all 100 requests. I want to make it in such a way that after every 40 seconds, each user only fires 1 request and that request has to be different from the previous request. I would like to know what kind of controller to use (or anything else) to achieve this scenario.

Thanks

like image 333
user1066568 Avatar asked Dec 01 '11 01:12

user1066568


People also ask

How do I hit multiple requests in JMeter?

You should add multiple "Thread Group" into a "Test Plan". Inside "Test Plan" Unselect "Run thread groups consecutively". Inside every "Thread Group" configure "Number of Threads(users)" as "1", "Ramp-Up Period" as "0", "Loop Count" as "1". Now, add "HTTP Request" into each "Thread Group".

What is the use of same user on each iteration in JMeter?

Same user on each iteration: On selecting the checkbox 'Same user on each iteration', when JMeter gets the cookie in the first response then it saves the cookie and uses in the following requests; provided that you have added HTTP Cookie Manager.

How does JMeter calculate request per second?

when you have one thread (user) sending requests to server and server responds after 100ms, you have 1 thread * 1000ms / 100ms = 10 transactions per second. when you have 10 threads sending requests to server and server responds after 100ms, you have 10 threads * 1000ms / 100ms = 100 transactions per second.

Why does JMeter stop sending requests?

also i am able to access the site under test from another system when JMeter stops sending request, it means server is not under load.


2 Answers

Try to use Random Controller.

The simplest way to implement your scenario:

Thread Group
Number of Threads = 5
Loop Count = N
    . . .
    Random Controller
        HTTP Request 001
        HTTP Request 002
        HTTP Request 003
        . . .
        . . .
        HTTP Request 100
    Test Action
    Target = Current Thread
    Action = Pause
    Duration = 40000
    . . .

This will iterate 5 threads N times.
Random Controller will RANDOMLY pick up on each step http request from "requests pool" - all the samplers added as children to Random Controller.
Test Action will pause thread for 40 secs.

Updated:
working illustration for above scheme:

Random Controller example

Thread Group
Number of Threads = 5
Ramp-Up Period = 0
Loop Count = 10

Constant Timer
Thread Delay (in ms) = 40000

You can download working example for described scheme from here: rc-plan.jmx.
This one works how you want (at least for me, Jmeter 2.5.1): it picks randomly ONE request from requests pool (in example - 10 requests) for EACH user (here - 5 users) on EACH step (here - 10 loops) and pauses each thread for 40 secs (Constant Timer).

You can also look into this mailing archive: Is their a way to randomize URL selection?.
Situation similar to your one seems to be described here.

...As per official documentation "Interactions between multiple controllers can yield complex behavior. This is particularly true of the Random Controller."

like image 101
Aliaksandr Belik Avatar answered Jan 12 '23 02:01

Aliaksandr Belik


Another option for you may be to create a CSV file with parameters for your requests ahead of time and use CSV Data Set Config to parameterize a single http request.

That obviously depends on how different your http requests are, but if it fits your requirements there are some potential bonuses with maintaining 1 http request in your test plan vs. 100.

The other details would be the same as @Alies Belik laid out -- one thread group configured for your required number of threads and loops, with a constant timer at the end for your 40 second pause.

like image 24
brentj Avatar answered Jan 12 '23 00:01

brentj