JMeter - How to batch threads in a thread group - jmeter

Is it possible to batch threads within a thread group? If I set the no. of threads (users) in a thread group to 75, is there way to specify launch 25 threads, wait for completion, launch next 25, wait and launch remaining 25.
Thanks,
J

Synchronizing Timer with Number of Simultaneous Users to Group by set to 25
Number of Simultaneous Users to Group by
Number of threads to release at once.

Create 3 thread groups with 25 threads each.
In the test plan, Check "Run Thread Groups Consecutively". In this way you are sure that next will execute once the first one is completed.

Related

Need to run threads groups in Jmeter when previous threads group's all threads is started

I have two thread group Thread group 1 and Thread group 2 in my test plan. Thread Group 1 has 15 users and Thread Group 2 has 20 users. Now I want to run my thread group 2 after threads ( 15 users) of Thread Group has been started.
Is there anyway to run like this.
To achieve this: use following steps:
Add multiple Thread Group in your Test Plan.
In this example, Thread Group - One has 10 Threads and Thread Group - Two has 1 Thread
To start Thread of Thread Group 2 after all the Threads of Thread Group 1, make sure you keep following settings in Thread Group 2
Check Scheduler check box
Start Up Delay should be greater than Ramp up period of previous Thread Group
Make sure to enter duration as well, otherwise you will get the error.
Add If Controller to first Thread Group and use the following __groovy() function as the condition
${__groovy(ctx.getThreadGroup().numberOfActiveThreads() == ctx.getThreadGroup().numberOfThreads,)}
Now you have a "trigger" which fires when all the threads defined in Thread Group are started. Now you can use i.e. Inter-Thread Communication Plugin in order to "tell" the 2nd Thread Group that it's good to go. Check out SynchronizationPluginsExample.jmx for reference implementation.
Add Startup Delay to group 2 which is greater than Ramp-Up Period of group 1
Make sure Test Plan Run Test Group consecutively check-box is un checked

Active Thread vs Concurrent Threads

I want 40 Active Threads, which are doing some kind of action... I have described my issue below
I am executing one of the test plans in which I am using jp#gc - Stepping thread group... In this, I have 40 concurrent users (this group will start)but when I execute this test... The ACTIVE threads are in different number (i.e less than 40).
How can I achieve 40 Concurrent and 40 Active threads?
If you need 40 concurrent active threads for a specific period of time, I would suggest you use the Ultimate Thread Group.
Here is an example:
Ultimate thread group Configuration:
Output of "Active Threads over time" Listener:
By using this, you can easily achieve 40 concurrent users at any time period.

JMeter - Run an amount of thread groups at a time

Basically, I have 30 thread groups in my test plan and I would like to run 8 thread groups at a time consecutively until the test plan is done.
The main test plan options only allow parallel testing of all threads of 1 thread group at a time.
Is there any other way to achieve this apart from segmenting the thread groups in different JMX files or toggling them?
I'm entirely sure what you mean but I'm going to assume you want to run 8 thread groups simultaneously for a certain period, and than start another 8 thread groups and run those for a certain period etc.
You could do this quite easily with the Stepping Thread Group plugin: http://jmeter-plugins.org/wiki/SteppingThreadGroup/. You can adjust each thread group's start and end time.

Executing threads (not thread groups) in JMeter sequentially

I have a Thread Group with the following property:
Number of Threads (users): 5
Now, when I run, all 5 threads launch concurrently.
Is there any setting or config element I can use to execute one thread at a time? In other words, I would like to execute Thread 2 only after Thread 1 has completed execution.
I believe the "Run Thread Groups consecutively..." option applies to "Thread Groups" and not to Threads.
1) you can use a Critical Section controller that will ensure only one thread runs at a time( put all your samples as its children)
2) you can play with rampup
3) you can set only one thread, and use loop iteration to 5

how to make jmeter Thread group sleep till all the threads in other thread group are active

I have 2 thread groups in jmeter project and when I run it, thread group2 starts paralelly along with threadgroup1. Is there a way I can make threadgroup2 to wait till all the threads in tg1 become active/running state?
Basically in threadgroup1 I am inducing the load and in threadgroup2 I have a thread which is integrated with selenium to capture the actual response time when the load is applied. Currently well before all the threads in tg1 are fired tg2 starts.
I think the easiest option would be to use the Startup delay in the Thread Group 2. delay period would be the rampup period (+ few seconds) of Thread group 1. By this time, JMeter would have started all the threads in the Thread Group 1.
Another approach would be to use to beanshell in the Thread Group 2 to calculate the total active threads of Thread Group 1. (assuming you only have 2 thread groups)
org.apache.jmeter.threads.JMeterContextService.getNumberOfThreads() gives total active threads of the Jmeter test.
ctx.getThreadGroup().numberOfActiveThreads() - gives the active threads in the current thread group.
so,
int grp1_thread_count = org.apache.jmeter.threads.JMeterContextService.getNumberOfThreads() - ctx.getThreadGroup().numberOfActiveThreads();
In the Thread group 2, use an If controller to check for the no of active threads of Thread Group 1 by using the value of grp1_thread_count to send the requests.

Resources