Create a stress test scenario

Updated at:

The WebSocket stress test feature in the PTS console lets you quickly create and run stress testing scenarios. This topic explains how to perform a stress test on a WebSocket service.

Background

WebSocket enables bidirectional data transfer between a client and a server. It is widely used in real-time communication scenarios such as message pushing and online chat. Stress testing WebSockets often involves installing a dedicated plugin in a tool like JMeter. However, setting up a JMeter environment requires time and coding knowledge. The WebSocket stress test feature in PTS simplifies this process. You can quickly build a WebSocket stress testing scenario in the PTS console. After the test, you can view a detailed stress test report and use the data to optimize your system.

Access the feature

  1. Log on to the PTS console. In the left-side navigation pane, choose Performance Testing > Create Scenario, and then click WebSocket Stress Test.

  2. On the Create WebSocket Scenario page, enter a scenario name.

  3. On the Scenario Configuration tab, click the expand icon next to + Add Test Node to add the required test nodes to a serial link.

Scenario configuration

Click the expand icon next to a serial link to expand it and configure basic information, output parameters, and checkpoints.

Basic configuration

On the Basic Configuration tab of the serial link, set the basic parameters for the test. The following table describes the parameters.

  • Establish Connection: Establishes a WebSocket connection between the stressor and the target. Other test nodes in a WebSocket stress test, such as heartbeat, read-only, write-only, and request-response, depend on this connection.

    Parameter

    Description

    Example

    Stress test URL

    The WebSocket URL of the target.

    wss://echo.websocket.org

    Connection timeout

    The maximum time, in milliseconds, to wait for a connection to be established.

    20000

    Response timeout

    The maximum time, in milliseconds, to wait for a response.

    6000

  • Heartbeat: Checks the connection status between the stressor and the target.

    Parameter

    Description

    Example

    Request type

    • send ping and expect pong: The stressor sends a ping message to the target and waits for a pong response to verify that the connection is active.

    • send only pong: The stressor sends a pong message to indicate that it is active.

    send ping and expect pong

    Response timeout

    The maximum time, in milliseconds, to wait for a response.

    Note

    This parameter is required only when Request Type is set to send ping and expect pong.

    6000

  • Read-only: The stressor only receives messages from the target.

    Parameter

    Description

    Example

    Data type

    The type of data to read. Valid values are Text, Binary, and Any.

    Text

    Response timeout

    The maximum time, in milliseconds, to wait for a message.

    6000

  • Write-only: The stressor only sends messages to the target.

    Parameter

    Description

    Example

    Data type

    The type of data to write. Valid values are Text, Binary, and Any.

    Text

    Request data

    The message content, which must match the selected data type.

    WebSocket Single Write Test

  • Request-response: The stressor sends a request to the target and receives a response.

    Parameter

    Description

    Example

    Data type

    The data type of the request. Valid values are Text, Binary, and Any.

    Text

    Request data

    The message content, which must match the selected data type.

    WebSocket Request and Response Test

    Response timeout

    The maximum time, in milliseconds, to wait for a response after sending the message.

    6000

  • Close Connection: Closes the connection between the stressor and the target.

    Parameter

    Description

    Example

    Status code

    The status code used to close the connection. This value can be customized.

    1000

    Response timeout

    The maximum time in milliseconds to wait for the connection-close status code.

    6000

Output parameter settings

On the Output Parameter Settings tab of the serial link, configure output parameters. For more information, see API output parameters.

Checkpoint settings

On the Checkpoint Settings tab of the serial link, configure checkpoints. For more information, see Checkpoints (assertions).

Controllers and timers (optional)

You can add controllers and timers as needed for your stress testing scenario.

  • On the Scenario Configuration tab, click + Add Controller and select a controller.

    • Loop Controller: Controls the number of times the test nodes within it are executed.

      After you select a loop controller, click the 循环控制器的更多图标 icon next to it, add the test nodes you want to loop, and set the number of loops. During the test, the nodes under this loop controller execute sequentially the specified number of times.

    • Transaction Controller: All test nodes under a transaction controller are measured as a single transaction. It includes two settings: Generate parent sample and Include duration of timers and pre- and post-processors in sample.

      • Generate parent sample:

        • Enabled: The stress test report does not show individual results for the test nodes under this transaction controller. Instead, it aggregates them into a single result for the transaction controller.

        • Disabled: The report shows results for both the transaction controller and each test node within it.

      • Include duration of timers and pre- and post-processors in sample: When enabled, the average response time of the transaction controller in the stress test report is the sum of the average response times of all test nodes, timers, and pre- or post-processors. When disabled, the average response time includes only the sum of the average response times from the test nodes.

    • Once Only Controller: Test nodes under a once only controller execute only once per virtual user.

  • On the Scenario Configuration tab, click + Add Timer and select a timer.

    • Constant Timer: Pauses the test for a fixed duration, specified in milliseconds.

    • Synchronizing Timer: This timer groups virtual users together. It waits until the specified number of simulated users has arrived, then releases them all at once. If the configured delay (timeout) is reached before the group is full, the timer releases all waiting users immediately.

    • Uniform Random Timer: A uniform random timer introduces a delay that consists of a fixed part and a random part. You can configure the Constant Delay Offset (the fixed part) and the Random Delay Maximum (the maximum value of the random part). The total delay is the sum of the constant offset and a random value between 0 and the random delay maximum. The random values are uniformly distributed, meaning each value has an equal probability of occurring.

    • Gaussian random timer: A Gaussian random timer is similar to a uniform random timer and is also used to set a delay. You can set a constant delay offset and a variable span. Use a Gaussian random timer if you require the random delay time to follow a normal distribution.

    • Constant Throughput Timer: Controls the throughput by pausing threads as needed to maintain a target throughput (in samples per minute). You can set a target throughput and a condition. The conditions include This thread only, All active threads, All active threads in current thread group, All active threads (shared), and All active threads in current thread group (shared).

Stress configuration

Click the Stress Configuration tab to configure the test execution parameters.

Parameter

Description

Stress source

The network type used for the stress test. Options include public network and Alibaba Cloud VPC. For more information, see Stress sources (public network and VPC).

Number of concurrent users

The number of virtual users that send requests concurrently. For example, 100 concurrent users means that the test will maintain a load equivalent to 100 active users.

Stress test duration

The recommended duration is at least 2 minutes. The maximum duration is 24 hours by default.

Traffic model

This is the incremental model for the number of concurrent users. When you select a different traffic model, the pressure estimation chart on the right side of the page also refreshes.

  • Linear increase: The number of concurrent users increases steadily from 0 to the maximum over the specified ramp-up period. The corresponding pressure estimation chart shows a straight diagonal line.

  • Stepped increase: The number of concurrent users increases in discrete steps over the ramp-up period. The load is held constant at each step for a short duration. The corresponding pressure estimation chart shows a step-like curve.

  • Fixed concurrency: The number of concurrent users is constant. The corresponding pressure estimation chart is a flat line, indicating that the test runs at the specified concurrency from start to finish.

Ramp-up period

The duration over which the number of concurrent users increases from 0 to the maximum value. This parameter is required when the Traffic Model is set to linear increase or stepped increase.

Number of steps

The number of discrete steps to take during the ramp-up period. This applies only when the Traffic Model is set to stepped increase.

Number of specified IPs

The number of unique source IP addresses to use for the stress testing agents. For more information, see Specify the number of stress testing IPs.

Custom traffic distribution

Simulate user traffic from different geographic regions. When enabled, you can configure the percentage of stress testing agents to use from various locations. For more information, see Customize regional traffic.

Start the stress test

In the lower-left corner of the page, click Debug Scenario to validate your configuration. For more information, see Debug a scenario. Then, click Save and Start Test and click OK in the confirmation dialog box to start the test.

Next steps

View the stress test report. For more information, see View multi-protocol stress test reports.