Stress test the RTMP protocol

Updated at:

This topic describes how to quickly run a stress test for the Real-Time Messaging Protocol (RTMP) in the PTS console.

Background

Streaming media is a technology that delivers media content. It works by compressing a continuous stream of data, such as video, audio, text, or images, and sending it in segments over a network for real-time playback. Without this technology, you would need to download the entire media file before viewing it. With the rapid development of 4G and 5G networks, streaming media has been widely adopted in various applications, including live streaming and video on demand (VOD). RTMP is a common streaming media protocol based on the TCP or UDP transport layer. The process can be simplified into two main phases: stream publishing and stream pulling. The RTMP stress testing feature in PTS validates the stability of your service by testing both stream publishing and stream pulling.

Access

  1. Log on to the PTS console. In the navigation pane on the left, choose performance testing > Create Scenario, and then click streaming media stress test.
  2. On the Create Streaming Scene page, enter a Scene Name, and select RTMP for Streaming Media Type.

  3. On the scene configuration tab, click the ul icon next to + Add Test Node to add test nodes to the target request chain.

Scene configuration

Click the ryi icon to the right of a serial link to expand it. Then, you can configure its basic information, output parameters, and checkpoints.

Basic configuration

On the Basic configuration tab of the serial link, configure the basic parameters for the test.

  • RTMP stream publishing: Simulates the process of publishing a stream, such as uploading captured content in real time during a live broadcast.

    Parameter

    Description

    ip

    Enter the domain name associated with stream publishing.

    port

    The default server port. For example, 1935.

    app

    Enter the application name. For example, live.

    stream

    Enter the stream name and token.

    video

    Enter the publicly accessible OSS URL for the video.

  • RTMP stream pulling: Simulates the process of pulling a stream, such as watching a live broadcast.

    Parameter

    Description

    ip

    Enter the domain name associated with stream pulling.

    port

    The default server port. For example, 1935.

    app

    Enter the application name. For example, live.

    stream

    Enter the stream name and token.

    Note

    For stream pulling, you only need to configure the app and stream parameters to determine the stream URL.

Output parameters

On the Output parameter settings tab of the serial link, configure the output parameters. For detailed instructions, see API output parameters.

Checkpoints

On the Checkpoint settings tab of the serial link, set checkpoints. For detailed instructions, see Checkpoints (assertions).

Controllers and timers (optional)

You can add controllers and timers as your task requires.

  • On the scene configuration tab, click + Add controller and select a controller.

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

      Select a loop controller and click the More icon for the loop controller icon to its right to add the test nodes to be executed in the loop and set the number of loops. During a stress test, the test nodes within this loop controller are executed sequentially for the specified number of times.

    • Transaction controller: A transaction controller groups all test nodes under it into a single transaction. It has two settings: Generate parent sample and Include duration of timers and pre-post processors in sample time.

      • Generate parent sample:

        • Enabled: The system does not report the individual test results for each node under this transaction controller. Instead, it aggregates and presents them as a single result for the transaction controller in the performance test report.

        • Disabled: The report displays test results for both the transaction controller and each individual node under it.

      • Include duration of timers and pre-post processors in sample time: If you enable this option, the average response time of the transaction controller in the performance test report is the sum of the average response times of all test nodes, timers, and pre/post processors. If you disable this option, the average response time includes only the sum of the average response times of the test nodes.

    • Once only controller: Nodes under a once only controller execute only once.

  • On the scene configuration tab, click + Add timer and select a timer.

    • Constant timer: Adds a fixed delay. This timer pauses execution for the specified duration in milliseconds.

    • Synchronous timer: You can set the Pause duration and the Number of simulated users. This timer holds threads until the specified number of users is reached, and then releases them all at once to create a burst of load. If the number of users does not reach the target within the timeout period, the timer releases the waiting threads.

    • Uniform random timer: This timer introduces a delay that consists of a fixed part and a random part. You can configure the Constant delay offset (the fixed delay) and the Random delay maximum (the maximum random delay). The total delay is the sum of the constant offset and a random value between 0 and the random maximum. Each random value in the range has an equal probability of being chosen.

    • Gaussian random timer: Similar to the uniform random timer, this timer also sets a delay with a Constant delay offset and a Random delay maximum. Use this timer when you need the random portion of the delay to follow a normal (Gaussian) distribution.

    • Constant throughput timer: This timer controls the throughput, ensuring that test nodes execute at a specified rate. You can set the target throughput and the basis for its calculation. The calculation can be based on: this thread only, all active threads, all active threads in current thread group, all active threads (shared), or all active threads in current thread group (shared).

Stress configuration

Click the Load Settings tab to configure the load settings.

Parameter

Description

Load Source

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

Number of concurrent users

The number of virtual users that initiate requests simultaneously. For example, a value of 100 means 100 virtual users are sending requests concurrently.

Test Duration

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

Traffic model

This setting defines the increment model for the number of concurrent users. When you select a different traffic model, the stress estimation chart on the right side of the page also refreshes.

  • Uniform ramp-up: The default model. The number of concurrent users increases at a constant rate per minute. The corresponding Estimated Load graph is a straight diagonal line.

  • Stepped ramp-up: The number of concurrent users increases in steps. The load on the system increases in stages; the number of concurrent users increases by a set amount in each time interval until the target is reached, after which the system maintains this concurrency for a period. The corresponding Estimated Load graph is a step chart.

  • Constant load: The number of concurrent users is constant. The corresponding Estimated Load graph is a flat horizontal line, indicating that the test runs with the specified number of concurrent users from start to finish.

Ramp-up period

The time it takes for all concurrent users to become active, starting from zero. You must configure this setting when the traffic model is set to uniform ramp-up or stepped ramp-up.

Number of steps

The number of steps to complete the ramp-up. You must configure this setting when the traffic model is set to stepped ramp-up.

Specified IP Addresses

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

Custom traffic region

Simulate user traffic from specific geographical locations by specifying the location of the stress-generating machines. After you enable this feature, you can configure the regional distribution of the stress machines to customize the geographical distribution of your test traffic. For more information, see Customize regional traffic.

Start the test

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

Next steps

View the performance test report. For more information, see View a multi-protocol performance test report.

Example scenario

The RTMP protocol supports both stream publishing and stream pulling. This section uses ApsaraVideo Live as an example to demonstrate how to use the RTMP stress testing feature.

  1. Activate live streaming in ApsaraVideo Live. For more information, see Activate ApsaraVideo Live.

  2. Configure live streaming settings in ApsaraVideo Live. For more information, see Add a domain name, Configure a CNAME record, Associate a push domain with a streaming domain, and Configure URL authentication. After configuration, you can view the added domain name in the domain management list.

  3. In the URL generator of ApsaraVideo Live, enter the stream name and application name to generate the streaming parameters. For more information, see Generate push and streaming URLs. The page also includes settings such as Streaming Domain, Associated Push Domain, Authentication Method, and Transcoding Template. After filling them out, click Start Generation.

    The results include a Push URL (RTMP format) and an Original Playback URL (supports RTMP, FLV, M3U8, and UDP formats). Each URL contains an auth_key authentication parameter. Click Copy to get the full URL.

  4. On the Create Streaming Scene page in the PTS console, configure a stream publishing node and run the test. For more information, see Scene configuration. On the Basic configurations tab of the RTMP stream publishing node, enter the stream publishing parameters obtained in the previous step into the corresponding ip, port, app, stream (including the auth_key authentication information), and video (the OSS URL of the video file) fields.

    Note

    The parameters for configuring stream pulling are similar. If stream publishing is active, you can test the stream pulling capability.