TFK
TFK

Reputation: 121

Introducing a delay between two thread groups in jmeter

I want to introduce some delay between two thread groups.

My test plan is-

  1. Thread Group 1 -

    a. Thread 1
    b. Thread 2
    c. Thread 3 (loop controller is added as a parent to thread 3. Loop controller is designed to run Forever)

  2. Thread Group 2

My plan is to start thread group 1 and then start thread group 2 after some delay. Once both thread group have started they should keep on running. I need to introduce a delay between thread group 1 and 2.

I have tried 2 methods below, but they did not serve my purpose.

  1. I selected Run Thread Groups consecutively from test plan, and introduced a test Action Sampler at the end of thread group 1 with

    Target: All Threads
    Action: Pause
    Duration: 5000

and added Synchronizing Timer as a child of the Test Action sampler and set Number of Simultaneous Users to Group by to the number of threads (virtual users) in the Thread Group 1.

  1. Simply added a Constant Timer before start of Thread Group 2.

What is a good solution for this?

Upvotes: 1

Views: 5859

Answers (1)

Dmitri T
Dmitri T

Reputation: 168042

  1. Your solution 1 is very good however you need to add a Test Action sampler to the very beginning of the Thread Group 2 as your current setup assumes it running in the end of Thread Group 1 like:

    • Thread Group 1
    • Wait 5 seconds
    • Thread Group 2
  2. Adding a Constant Timer between thread groups is absolutely not something you want to do as given you have the constant timer at the same level as Thread Groups it means the delay will be applied to each and every sampler. You need to move the timer to be a child of the first request of Thread Group 2. Timer will execute before the request which seems to be something you're looking for. See Advanced Load Testing Part 3 - Top 4 Timers article to learn more about timers use cases and best practices
  3. And finally probably the fastest and the easiest solution would be setting a Startup delay for 2nd Thread Group. It can be done under "Scheduler" section:

    JMeter startup delay

    as per the documentation:

    If the scheduler checkbox is selected, one can choose a relative startup delay. JMeter will use this to calculate the Start Time, and ignore the Start Time value.

Upvotes: 4

Related Questions