I posted a question previously about how to delay all the threads in a thread group until the last one had ramped up completely. It was suggested I use a Synchronization Timer and it seemed like the right timer to use. However I have subsequently found that the Synchronization Timer is not only delaying all threads, like I want it to, my test is now only executing the next request after the previous one completely finishes for all requests.
My test is set up like this:
Test (20 threads)
Login (Transaction Controller)
Do Something (Transaction Controller)
Synchro Timer (to wait until all users have logged in)
HTTP Request 1
HTTP Request 2
...
So for above example:
All 20 users ramp up and are logged in
Once all users are logged in 20 HTTP Request 1s are executed simultaneously
Only after all 20 HTTP Request 1s have received a response then 20 HTTP Request 2s are executed
While I'm after the first lot of 20 HTTP Request 1s to be fired off at the same time, I want the following HTTP Request 2s to be executed progressively as the HTTP Request 1s responses return. I don't want the wait here.
How can I do this?
According to the documentation on timers:
Note that timers are processed before each sampler in the scope in which they are found; if there are several timers in the same scope, all the timers will be processed before each sampler.
Timers are only processed in conjunction with a sampler. A timer which is not in the same scope as a sampler will not be processed at all.
To apply a timer to a single sampler, add the timer as a child element of the sampler. The timer will be applied before the sampler is executed. To apply a timer after a sampler, either add it to the next sampler, or add it as the child of a Flow Control Action Sampler.
Please be informed about JMeter Scoping Rules, according to your setup the Synchronizing Timer is applied to all HTTP Request samplers under the Transaction Controller while according to your description you need to apply it only to the HTTP Request 1
Make the Synchronizing Timer a child of the HTTP Request 1 and it should resolve your issue.
Related
How can I use if in GROOVY to write a condition for a request so that a request is sent every 10 minutes? I used the constant throughput timer, but this module was applied to all sampler in the thread group.
I want to send 70000 http requests in JMeter, but I want to do it such that I send 50 requests in one go, then pause for around 6 mins, then send the next 50 and so on until I hit a total of 70000 requests
So far, I have tried a couple different configurations to try this, for eg.
- Thread group (with number of threads = 1, Ramp-up period = 1, Loop Count = 1400)
- Loop Controller (Loop count = 50)
- HTTP Request
- HTTP Header Manager
- Constant Timer (Thread Delay (in milliseconds) = 600000)
But this doesn't seem to work. This just seems to fire one request every 1 min (or 600000 milliseconds).
I have also tried
- Thread group (with number of threads = 1, Ramp-up period = 1, Loop Count = 1400)
- Loop Controller (Loop count = 50)
- HTTP Request
- HTTP Header Manager
- Constant Timer (Thread Delay (in milliseconds) = 600000)
But it gives me the same result.
JMeter's elements are all about scopes and execution hierarchy. In order to achieve your goal, you can place your timer in 2 ways
Use "Flow Action Control" Sampler after your HTTP request or in the scope of your Loop Controller or under the scope of your Thread Group (right click on thread group and select "Add Think Times to Children"
Place the timer inside the HTTP Request before which you want the Timer to be executed
Sample Screenshots
Flow Action Sampler
Timer inside a sampler
Why you are facing an issue
Basically below is the hierarchy in which JMeter executes your elements
Configuration Elements
Pre-Processors
Timers
Samplers
Post-Processors
Assertions
Listeners
Source: https://jmeter.apache.org/usermanual/test_plan.html#executionorder
Since timers have a higher execution priority than samplers, they are bound to get executed before a sampler gets executed. In your particular case, you have placed your timer in the scope of both Loop Controller & Thread Group and hence it is getting executed before each element.
Note that timers are processed before each sampler in the scope in which they are found; if there are several timers in the same scope, all the timers will be processed before each sampler.
Timers are only processed in conjunction with a sampler. A timer which is not in the same scope as a sampler will not be processed at all.
To apply a timer to a single sampler, add the timer as a child element of the sampler. The timer will be applied before the sampler is executed. To apply a timer after a sampler, either add it to the next sampler, or add it as the child of a Flow Control Action Sampler.
Source: https://jmeter.apache.org/usermanual/component_reference.html#timers
How the suggested solution works from Timer perspective
Since I am placing the Timer inside a sampler, it gets invoked only before that particular sampler executes. Hence we avoid the timer being applied to every other element
Also, Flow Action Sampler is a sampler itself and hence it gets executed only in the sequential manner and hence when you place it after your respective HTTP request, it will execute only at that instance and hence it will act as expected
How to be used in your Test Plan
With Loop Controller
For my example I am taking a scenario where I simulate 50 requests, wait for 10 seconds and trigger the next bunch of 50 until 500 requests are reached
Added the Flow Action Sampler inside my loop controller
Defined 50 Threads for my sample test
Loop count in Loop controller is 10
Once I trigger the test, during the first second, all my 50 users have ramped up and triggered 50 requests and are now waiting for 10 second duration. Notice the number of samples, thread count and time
During the 7th iteration, 350 requests have been completed and they are about to reach 70th second
At the end of the test, I have 500 requests. Expectation from my test scenario is that post burst of 50 requests, wait for 10 seconds and continue this pattern for 10 iterations. Hence at the end of the test (~100 seconds later), I will have 500 samples completed.
Without Loop Controller
Follow similar test plan as defined with loop controller, only difference being, non-existence of the loop controller and loop count in Thread Group will be defined as 10
In either case, Flow Action Sampler has 10 seconds as Pause time
Hope this helps!
Set time gap/timer between 'foreach controller' requests.
We have a below scenario:
Login single user>click question multiple times
To achieve above scenario in Jmeter used below Test Plan:
ThreadGroup - 1 user, 1 ramp up period, 1 loop
-HTTP request to login
-Questionslist - RegExp to get list of questions with -1
-ForEach Controller - 100 times loop count
--HTTP request
When 'Timer' is set under 'ForEach controller' doesn't actually considered this timer value (ex: 2000 milliseconds)
Please guide how to have time gap between 'ForEach controller' http request.
Actually Constant Timer should work however you will not see this delay anywhere as by default the duration of PreProcessors, Post-Processors and Timers is not included into Sampler time.
You could put your HTTP Request and the Timer under Transaction Controller and configure it to:
Generate Parent Sample
Include duration of timer and pre-post processors in generated sample
This way you will get Timer time (2 seconds) added to your Sample Result.
However above approach is on per-user basis, it means that each virtual user will have a 2-second delay between HTTP Request. If you would like to have 2 seconds of absolutely idle time, i.e. when no requests are being made at all you can add a Test Action sampler after HTTP Request sampler and configure it to produce a 2000 ms delay. Also put Synchronizing Timer as a child of the Test Action sampler and set Number of Simultaneous Users to Group by to be equal to the number of virtual users in Thread Group - this way Test Action sampler will act as a rendezvous point and all the virtual users will "meet" there to "sleep" together for 2 seconds.
Assume I have two users in Thread Group and want them to fire two requests simultaneously. User 1 - HTTP Request A and User 2 - HTTP Request B.
Any ideas how to implement that ?
To trigger the requests simultaneously, you need to place your each requests in different thread group as shown below.
Also, make sure that in the Test Plan, below option is unchecked.
Above settings will execute the request simultaneously. Below is the sample output.
Just add Synchronizing Timer to your Thread Group and set Number of Simulated Users to Group by to 2 like:
The Synchronizing Timer will pause the first thread until second one is ready to execute the HTTP Request sampler so both threads will be run simultaneously. See Using the JMeter Synchronizing Timer article for more details.
I wanted to execute a Test Plan as Below.
Example : I wanted every http request should take delay of two minutes
http_request_1,
delay (2 minutes)
http_request_2
All request are in same thread group
Create a transaction controller in Thread group
put all your http requests under this transaction controller
add constant timer (with value as 2 min) to transaction controller
(this way it will be applicable to all request within that transaction controller)
run your jmeter script
or if only 2 request are there then add only 1 constant timer in between both the requests.
The simplest way is to add a single 'Constant Timer' to your thread group at the same level as your HTTP requests.
Right click Thread Group > Add > Timer > Constant Timer.
Set the timer value to however many milliseconds you need (in your case 120000), and it inserts a delay between all requests in that thread group.
Create a transaction controller in Thread group
put all your http requests under this transaction controller
add constant timer (with value as 2 min - please find the 2nd screen-shot) to transaction controller
(this way it will be applicable to all request within that transaction controller)
run your jmeter script
or if only 2 request are there then add only 1 constant timer in between both the requests. Please find below screen-shot