Henry Bui
Henry Bui

Reputation: 703

How can I decrease the threads while running jMeter?

I create a test plan when working with jMeter, and I want to create a test plan with 100 concurrency users.

After first page(homepage) I want to decrease 50 users(drop-off and do not access to next page) while 50 another users continue access to another page.

Someone suggested me use Ultimate Thread Group but I think it can't help.

Any idea for this issue?

Upvotes: 2

Views: 613

Answers (2)

ararar
ararar

Reputation: 983

You can add a Throughput controller after your home page, and add all the requests you want to be executed with only 50 users into the throughput controller. you have two options :

  • percent executions: A number from 0-100 that indicates the percentage of times the controller will execute. "50" means the controller will execute during half the iterations through the test plan.

  • Total executions: For total execution mode, the number indicates the total number of times the controller will execute.

Check Throughput Controller from Jmeter user manual for more information.

Upvotes: 0

Dmitri T
Dmitri T

Reputation: 168157

If you need to shut down half of threads after 1st request you can do it as follows:

  1. Add If Controller after the first request
  2. Put the following expression in the "Condition" area:

    ${__threadNum} % 2 == 0
    
  3. Add Test Action sampler as a child of the If Controller and configure it as follows:

    • Target: Current Thread
    • Action: Stop

Explanation:

  • __threadNum() function returns current Thread number
  • If current thread number is even (2, 4, 6, 8, etc.) this thread goes to the Test Action Sampler therefore it is being shut down
  • So first sampler will be executed by 100 threads, second (and following samplers) will be executed by 50 threads as only 50 will remain
  • Test Action sampler doesn't generate any results so it is fine to useit, it won't appear in the test metrics

Example Test Plan structure:

JMeter shut down half of threads

Upvotes: 3

Related Questions