All Products
Search
Document Center

Performance Testing:Get Started with JMeter stress testing

Last Updated:Dec 12, 2024

To initiate a JMeter stress test, you must create a JMeter stress testing scenario and import a JMeter script from an on-premises device to the scenario. This topic describes how to quickly initiate a stress test for a web page by using simple configurations.

Prerequisites

  • PTS is activated.

  • This example uses Apache JMeter 5.6.3 to create scripts. PTS supports JMeter 5.0 and 5.6.3.

Procedure

To use the JMeter feature, you must create a stress testing script by using Apache JMeter on your on-premises device. Then, upload the script to a JMeter stress testing scenario and start the stress test defined in the scenario. Perform the following steps:

Step 1: Use Apache JMeter to create a script

  1. Configure HTTP request parameters, including the server name or IP address, port number, and request method. image

    Description of the parameters on the Basic tab:

    • Protocol: In this example, select http.

    • Server name or IP: Enter the domain name of the web page that you want to test. Example: www.example.com.

    • Port Number: Enter the port number used to access the web page. Example: 80.

    • Method: Select GET.

  2. Run the test plan and view the results in the View Results Tree. The following response information indicates a successful upload. image

  3. After successful debugging, export the test plan file, named HTTP_Request.jmx here.

Step 2: Create a JMeter stress testing scenario and start the stress test defined in the scenario

  1. Log on to the PTS console, choose Performance Test > Create Scenario, and then click JMeter.

  2. Orchestrate a stress testing scenario.image

    Take note of the following parameters:

    Scene: Enter test-jmx.

    Upload files: On the Scene Assembly tab, upload the JMeter script file named HTTP_Request.jmx.

    JMeter version: Select 5.6.3. Make sure that the JMeter version that you select is the same as the Apache JMeter version that you use to create the script on your on-premises device. Otherwise, errors may occur.

  3. Configure load settings

    Set the maximum virtual users to 10 and the test duration and increment duration to 2 minutes. Use the default settings for other parameters. You are charged for stress tests. We recommend that you configure a load level based on your business requirements. For more information, see Billing overview and Configure the stress testing model and level. image

  4. Debug the scenario.

    You can debug the scenario to check whether the configurations are valid and prevent test failures. We recommend that you debug the scenario. For more information, see Debug a stress testing scenario. The following figure shows a successful request. If the response status code is not 200 for an API request, check whether the API request can be initiated as expected.image

  5. Click Save and Start. On the Note page, select Execute Now and check The test is permitted and complies with the applicable laws and regulations. Then, click Start.

Analyze stress test results

After the stress test is complete, the system automatically obtains the data generated during the test, including the stress testing scenario metrics, business details, monitoring details, and API sampling logs, and generates a stress testing report. You can view the report on the Stress Test Report page. For more information, see View a JMeter performance testing report. image

FAQ

JMeter stress testing may fail due to mismatched JMeter versions between the PTS console and the on-premises device, incomplete upload of jar plug-ins, local file paths configured in the script, or issues with load allocation. You can use one of the following methods to resolve the preceding issues:

  1. Although later versions of JMeter are generally compatible with earlier versions, hidden issues may exist. Make sure that the JMeter version on the PTS console is the same as the version on the on-premises device. Make sure that scenario debugging is complete before a stress testing is started. JMeter 4.x is not supported.

  2. Upload the jar plug-ins and data files used for on-premises device to the JMeter stress testing scenario along with the script. Do not omit any files.

  3. Delete the local file paths written for on-premises device and retain only the file names when the files are used in the script. The load generator in PTS and the local file system are different. If the local file paths are not removed, errors may occur.

  4. PTS rewrites the script during stress testing to obtain specified load values. However, the original script is not overwritten. The following describes how to rewrite a script during stress testing:

    The number of concurrent threads specified in the PTS console minus the number of threads in the setUp Thread Group and tearDown Thread Group is allocated in the Thread Group. If the difference is 0, the number of threads to be allocated is 0. PTS only rewrites JMeter script in the Thread Group. For example, if a scenario specifies the number of concurrent threads as 500, and a script sets three Thread Groups with the ratios of a:b:c (excluding setUp Thread Group and tearDown Thread Group), PTS allocates the number of 500 to the three Thread Groups with the ratios of a:b:c.

    In this case, you must clear the types of thread groups in a script before stress testing. If a script contains only one Thread Group, set the number of threads in the Thread Group to 1. If a script contains multiple Thread Groups, set the number of threads in each Thread Group to the same number if you want the load to be evenly allocated in each Thread Group, or set the number of threads in each Thread Group proportionally if you want the load to be proportionally allocated in Thread Groups.

References