I am trying to run the same thread group after a certain interval. Example -
JMeter will run thread group A and execute all http requests inside it and let's say for example after 20 sec it will run thread group A again and this loop should carry on until I manually stop the script.
What I have designed right now is something like this-
Thread Group A
While Controller (I gave some condition so that it is always true)
Http request 1
Http request 2
Constant timer (20sec)
but this only puts 20sec delay between each http call.
Replace Constant Timer with the Test Action sampler, keep all defaults and set "Duration" to 20000 milliseconds
Add Syncrhonizing 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 threads in your Thread Group
That's it, synchronizing timer will act as a "rendezvous" point so all your virtual users meet there and wait for 20 seconds together.
You might also be interested in How to Easily Implement Pacing in JMeter in order to be able to configure more complex delay scenarios
Related
I am running one scenario for 2 hours in which I am using service which generates the cookie.. and that cookie is getting expired after 30 minutes.
So I want to create a thread group which will run after 30 minutes so that new cookie will get replace with old cookies.
You can setup another thread group with a 30min startup delay.
Add a constant timer with 30min to ensure the delay after the first execution.
Best approach could be to check the expiry with a If Controller and add the requests within the if controller.
To make this simple
Create a thread group with number of threads as 1 with ramp up as 1 second.
Create a loop controller and add loop count as 4.
Create your request under this loop controller and also add constant timer as child of your request as shown below :
Execution flow will be:
First request will get executed . Once this first request gets a response from the server, it will wait for 30 mins. Then this loops again 4 times. You can control the number of execution in the loop count.
The options are in:
Just specify "Startup delay" for the Thread Group:
Add Flow Control Action sampler as the first sampler in the Thread Group and configure it to pause for the half and hour:
Use custom thread group like Ultimate Thread Group (can be installed as a part of Custom Thread Groups bundle using JMeter Plugins Manager) where you can precisely define when and how to start threads:
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!
I'm having a question about how the requests are processed,
For example:
I have created a test plan, with one thread group.
Set number of users (thread): 10
Ramp-up period: 20
Loop count: Forever
Within this thread group I have created 5 HTTP requests.
When I hit start, I understand that it starts with 1 user, and by 20th second it will have all 10 users.
Does each sampler (http request) get assigned to 1 user? Is each sampler fired in sequential order? Does it fire parallel requests? I am trying to understand overall working.
JMeter starts threads (virtual users) within the bound of the ramp-up period. In your case JMeter starts with 1 user and adds another user each 2 seconds.
When thread (virtual user) is started it starts executing Samplers upside down (or according to Logic Controllers)
When there are no more samplers left to execute the thread starts over (if the number of loops is > 1), otherwise it is shut down.
With regards to concurrency, it mainly depends on the number of threads and application response time, you can observe how many virtual users were online using Active Threads Over Time listener and the delivered load using Server Hits Per Second. The aforementioned listeners can be installed using JMeter Plugins Manager
Each thread is sequential firing HTTP requests based on your flow
But you are executing 10 threads/users in parallel, so the order of the requests in total isn't sequential, but parallel
If you defined loop count as 1, then each sampler (http request) would get assigned to 1 user,
But you are looping endlessly, so samplers can be executed more than once per user/thread
About Loop Count: (asked in comment)
Loop Count - the number of iterations for each Thread.
I have written a simple test plan with the following steps
Test Plan
View Results in Table
Aggregate Report
Thread group
Threads: 5
Ramp-up period: 0s
Loop count: 1
Inside Thread Group
A dummy sampler to prove that all threads are running concurrently
HTTP request to upload a file
When I run the above tests, the dummy sampler is executed nearly the same time. However, I realize that only 1 thread can execute the HTTP request to upload file at a time, even when I have multiple threads. So the final result will be Thread 1 upload file -> finish -> Thread 2 upload file ... e.t.c.
Is this a normal behaviour and can I make file upload performs concurrently from multiple threads?
It depends on the number of threads, loop count and ramp-up period. JMeter starts threads within the time frame you specify in "Ramp-up period" input and the threads start executing samplers upside down (or according to the Logic Controllers). When there are no samplers to execute or loops to iterate the thread is being shut down.
If you need to configure JMeter to execute a certain request at exactly the same time by several threads add Synchronizing Timer as a child of this request and configure "Number of Simulated Users to Group by" setting to match the number of simultaneous users
Example execution:
As you can see, Dummy Samplers were started in 2 seconds while HTTP Request samplers were executed at nearly the same moment.
See Using the JMeter Synchronizing Timer article for more information on implementing these "rendezvous points" in JMeter tests
I am trying to achieve goal of 3 TPS using all my threads. I used Constant Throughput Timer but somehow it doesn't provide constant TPS. It does go beyond 3 TPS like sometime 10TPS.
Test Scenario
Thread Group 1
This Thread group submit XML on server and check the status.
I put constant Timer under this Submit Quote action and set value as 3 per min.
After each Quote Submit i will perform some action.
Thread Group 2
This Thread group submit XML on Server and check the status as like first Thread group but the rest action are different than first.
I put constant Timer under this Submit Quote action and set value as 3 per min.
Thread Group 2
This Thread group submit XML on Server and check the status as like first & Second Thread group but the rest action are different than first & Second.
I put constant Timer under this Submit Quote action and set value as 3 per min.
I need 3 TPS from all these Thread Groups for Submit Quote step, i am able to achieve that somewhat but it's not constant.
Can some please help to manage TPS?
Below is the Graph you can see some high transactions:
CTT will give you "constant" throughput after some time, not in such reduced time as your test shows.
The peak you see come from variation of your server response time.
Maybe you can try this method:
Configure thread group :
Loop count = 1
Ramp up period = time of your test (3600 seconds for my example)
Delay Thread creation until needed = true
Scheduler duration = 3600 seconds
Scheduler startup delay = 0
if you run for 1 hour, to achieve 3 Trans per minute, set number of threads to 180.
I am able to manager this up to some extend by separating actions in to multiple threads. In my earlier example in Thread 1 i was performing some action which impacted CTT. To resolve issue, i am using Queue concept.
First separate your thread's, if any action in your takes time move them to separate thread. In below example actions QuoteStatus and further were part of my thread 1 and due to slow response from server it was not allowing me CTT.
If you look at above response time from Thread one its pretty constant, having multiple actions is one thread cause issues. If your goal is to put constant throughput, it would be good to keep one action each thread and then use Inter_Thread Communication to pass data in other threads.