If multiple thread groups exist in a JMeter test plan, you need to know how to perform parallel or serial performance testing on multiple thread groups by configuring parameters in JMeter and Performance Testing (PTS).
Background
Apache JMeter includes thread group, setup thread group, and teardown thread group:
Thread Group: The thread group is one of core components of a test plan. The thread group defines behavior simulation of tested users and controls the number of virtual users (thread) and the behavior and lifecycle of the virtual users.
Setup Thread Group: The setup thread group is a special thread group type that performs some initialization operations before PTS. Normally, the setup thread group prepares a test environment or sets prerequisites for PTS, such as establishing a database connection.
Teardown Thread Group: The teardown thread group is a special thread group type that performs cleanup operation after a PTS plan is completed. Normally, the teardown thread group restores the test environment or closure works. In this way, any changes to a system during PTS can be revoked, such as closing a database connection.
The concurrency and number of loops configured in PTS exclusively overwrite the configuration of main thread group in the JMeter script, leaving the setup thread group and teardown thread group unaffected.
Set parallel or serial multiple thread groups
If the JMeter script contains multiple main thread groups, you can set parallel or serial multiple thread groups by referring to the following instructions.
The Loops in the PTS load settings are applied to all thread groups. Once the Test Duration is complete, the entire performance testing stops.
Parallel multiple thread groups
When multiple thread groups are running in parallel, the execution time is determined by which comes first: the Loops or the Test Duration. For example, suppose the test duration is set to 10 minutes, and the loops are set to 5 times. In this case, if completing all 5 loops only takes 5 minutes, the performance testing stops at the 5-minute mark.
When multiple thread groups are running in parallel, do not select Run Thread Groups consecutively (i.e one at a time) in the Test Plan properties in the local JMeter script. This means all thread groups start at a time and each thread group is running independently. The parallel multiple thread groups support the following scenarios:
Parallel load test: If you want to simulate multiple users to access a system at a time, you can set the parallel multiple thread groups. For example, you can set different types of user behaviors in multiple thread groups.
Simultaneous test in different scenarios: If you need to test different scenarios or functional modules at a time in a test plan, you can set the parallel multiple thread groups.
Reduce test duration: Setting the parallel multiple thread groups can reduce the test duration because all thread groups runs at a time.
Serial multiple thread groups
The serial scenario is slightly more complex, and the operations are as follows:
When debugging a JMeter script locally, select Run Thread Groups consecutively (i.e. one at a time) in the Test Plan properties. This means thread groups run in sequence, and the next group starts only after the previous one has completed). This is especially useful for the test by stages. For example, starting load test only after some initialization tasks have completed.
Set the Loops in PTS. The number of loops is applied to each thread group. For example, suppose a test plan contains three thread groups, namely A, B, and C, and the number of loops is set to 5 times in the PTS load settings. In this case, the execution sequence is 5 loops based on the concurrency of A, 5 loops based on the concurrency of B, and 5 loops based on the concurrency of C.
The Test Duration set in PTS must be long enough to prevent interruption during serial performance testing on multiple thread groups. The estimated duration of performance testing is calculated as the RT of the service request multiplied by the total number of requests. You can extend the duration based on the estimated duration of performance testing.