Search code examples
testingjmeterperformance-testingload-testing

How to run threads concurrently in jmeter


Hi i have created a thread group which contains 10 transaction controller, each control has multiple number of HTTP request samplers. Now to identify the bottleneck as per the requirement, each transaction control has to run one after another. enter image description here For ex: 30 threads- Register and login. send reports and logout is the scenario. so, For each action i have created 1 transaction controller which contains required http sampler request. First i need to run register for 30 users. after getting the response for all 30 users then only login transaction controller should run. and so on.. one by one. I tried creating multiple thread groups but i am fetching security tokens in each group. So if i create multiple thread group i cant call variable values of one thread group in another. So pls if anyone know the solution help me out, i am a beginner to jmeter...


Solution

  • This can be achieved using only 'Synchronizing Timer' element of the JMeter. Please find below the brief description of this element:

    • Synchronizing Timer: This element is used when you intentionally want to pause the users/threads at a specific step until the count of user mentioned in this element is reached

    You can create your script in following structure:

    • Transaction Controller for Register requests
      • HTTP Register Request1
      • HTTP Register Request2
    • Transaction Controller for Login requests
      • HTTP Register Login1
        • Synchronizing Timer [Set the 'Number of Simulated Users to Group by' to 30 and Timeout based on your requirement [Recommended value to set is '300000' i.e 5 minutes]. Do not set Timeout to '0' otherwise your test will remain in running state forever if any of the user gets failed in previous step]
      • HTTP Register Login2
      • HTTP Register Login3

    enter image description here

    Note: In above example, you can see I have added synchronizing timer as a child of first HTTP sampler request of under Login transaction controller.

    When the test reach at 'HTTP Register Login1' then before sending this request, it will perform the synchronizing timer and wait for all the users to complete the register action.

    For beginners, the following blog posts of RedLine13 are very useful to jump start on JMeter:

    https://www.redline13.com/blog/kb/
    

    Also, the response time will definitely increase when you use the synchronizing timer because this timer will pause the test until all user reached the step and then perform the login operation. As all 30 users will perform the login action at the same time so the response time will go high as compared to the case when some users are doing registration and others doing login.

    Kindly let me know if you have any questions.