Create a traffic playback and stress testing task

更新时间:
复制 MD 格式

To prepare for an upcoming short-term business peak or a database schema change (especially an index change), you can use the traffic playback and stress testing feature. This feature helps you determine if your database instance needs to be scaled out and verify its performance in a real-world business scenario, reducing the risk of failures after deployment. Additionally, if a database fails and you cannot locate the cause, you can use a cloned database to reproduce the failure and locate its cause.

Prerequisites

  • Supported source databases:

    • RDS MySQL

    • PolarDB for MySQL

      Note

      PolarDB for MySQL Enterprise Edition single-node instances are not supported.

  • Supported destination database instances:

    • RDS MySQL.

    • PolarDB for MySQL.

    • PolarDB-X 2.0.

  • The source and destination database instances are connected to DAS. For more information, see Connect an Alibaba Cloud database instance to DAS.

  • For the source database instance, DAS Enterprise Edition and the SQL Explorer feature must be enabled. The storage duration for log indexes must be 7 days.

  • For the destination database instance, DAS Enterprise Edition and the SQL Explorer feature must be enabled. The storage duration for log indexes must be 7 days.

  • Database instances in Alibaba Gov Cloud and Alibaba Finance Cloud are not supported.

Scenarios

  • Determine whether your current database instance needs to be scaled out to handle upcoming short-term traffic peaks.

  • After a database schema evolution, especially after an index change, you can validate its effect in a real-world service scenario. This reduces the threat of failures after the change goes online.

  • If a database fails and you cannot find the cause, you can use the intelligent stress testing feature to reproduce the failure scenario on a clone database and identify the cause.

Usage notes

  • To reduce the impact of network latency on stress testing, the stress testing client and the destination instance must be in the same region.

    Note

    We recommend that you place the stress testing client and the destination instance in the same VPC.

  • Before you perform stress testing, verify connectivity between the stress testing client and the destination instance to ensure that traffic can be sent.

Billing

  • For information about the fees for DAS Enterprise Edition, see Billing.

  • After you create a stress testing task, the following items are billed:

    • If you select Restore by Backup for data migration, the system automatically creates a pay-as-you-go database instance based on the destination database engine that you select. The system also enables the latest DAS Enterprise Edition for the new instance, along with 30-day storage for SQL logs and 7-day storage for log indexes.

    • If you select DAS Automatic Purchase and Deployment in the Advanced Settings section, the system purchases a pay-as-you-go ECS instance of a suitable instance type based on the QPS of the source database and the playback speed multiplier. For more information, see ECS billing overview.

    Note

    Because the system purchases pay-as-you-go instances, you must manually delete them after the stress testing task ends to avoid unnecessary charges.

Procedure

  1. Log on to the DAS console.

  2. Go to the Traffic Playback and Stress Testing page.

    You can go to the Traffic Playback and Stress Testing page in one of the following ways:

    • In the left-side navigation pane, click Tools > Traffic Replay & Stress Testing.

    • Go to the page from the instance details page.

      1. In the navigation pane on the left, click Intelligent O&M Center > Instance Monitoring .

      2. Find the target instance and click the instance ID to open the instance details page.

      3. In the left-side navigation pane, click Request Analysis > SQL Explorer and Audit. Then, on the page that appears, click Traffic Playback and Stress Test.

  3. On the task list page, click Create Task in the upper-right corner.

  4. In the Create Task dialog box, set the following parameters.

    1. Set Task Type to Cloud Instance Playback and enter a Task Name.

    2. In the Source Information section, set the following parameters and click Next.

      Configuration

      Description

      Instance Source

      Select Alibaba Cloud Database.

      Database Engine

      The engine of your database instance. Options include:

      • MySQL: an RDS MySQL instance.

      • PolarDB for MySQL: a PolarDB for MySQL instance.

      • PolarDB-X: a PolarDB-X 2.0 instance.

      Source Instance

      Select the ID of the Source Instance.

      Advanced Settings

      Batch Stress Testing

      The task pauses after the preparation phase. You can then select multiple tasks from the task list and start the stress test for all of them simultaneously.

      SQL Type

      Select one or more SQL types to test.

      Database Account, Password

      The account and password of the source database.

      Note

      Click Obtain Database to retrieve the database list. If you want to perform stress testing on all databases, you do not need to select any. If you want to test specific databases, you can select up to five databases.

    3. In the Generation Method of Schema and Data of Destination Database section, set the following parameters.

      Configuration

      Description

      Database Engine

      The engine of the destination database instance. The following types are supported:

      • MySQL: an RDS MySQL instance.

      • PolarDB for MySQL: a PolarDB for MySQL instance.

      • PolarDB-X: a PolarDB-X 2.0 instance.

        Note

        PolarDB-X 2.0 is supported only in the China (Hangzhou), China (Shanghai), China (Beijing), China (Shenzhen), and Singapore regions.

      Benchmark Data Migration

      Select a migration method based on whether the source instance's benchmark data has been migrated to the destination instance:

      • Restore by Backup: The destination instance is cloned from the source instance based on a point in time or a backup set.

        Note

        DAS automatically purchases a pay-as-you-go instance with the same specifications as the source instance. The latest DAS Enterprise Edition and the SQL Explorer feature are enabled for the instance by default, the storage duration for log indexes is set to 7 days, and the backup data is restored to the instance.

      • Data Migration Completed: The table schema and data of the source instance from the traffic playback time range have been synchronized to the destination instance.

        Note

        The schema and data of the destination instance must be consistent with those of the source instance to ensure that the stress testing traffic runs as expected.

      • Enter DTS Task ID: A data migration task has been created in the DTS console to synchronize data from the source instance to the destination instance.

        Note

        For more information about data migration by using DTS, see Data Migration.

      • Create DTS Migration Task: Directly create a data migration task without navigating to the DTS console.

        Note

        Different link specifications provide different migration link performance. For more information about how to select a link specification, see Migration link specifications.

      Note
      • If the source instance is an Alibaba Cloud database, you can select any of the four methods. We recommend that you select Restore by Backup because the system automatically purchases a pay-as-you-go instance with the same specifications as the source instance and restores the data to that instance after the stress testing task is created.

      • If the source instance is a self-managed database, you can select only Data Migration Completed, Enter DTS Task ID, or Create DTS Migration Task.

      Restore Mode

      Select a restore mode. You can select one of the following modes as needed:

      • By Time Point

      • By Backup Set

      Note
      • This parameter is required when Benchmark Data Migration is set to Restore by Backup.

      • If you set Restore Mode to By Backup Set, you must grant permissions to the DAS Service-linked Role. In the dialog box that appears, click OK.

      Select Restore Time/Backup Set

      Select a restore time or backup set based on the selected Restore Mode.

      Note

      This parameter is required when Benchmark Data Migration is set to Restore by Backup.

      Migration Task ID

      The ID of the DTS data migration task that synchronizes data from the source instance to the destination instance.

      Note

      This parameter is required when Benchmark Data Migration is set to Enter DTS Task ID.

      DTS Migration Task Specifications

      Select the DTS migration task specifications.

      Note
      • This parameter is required when Benchmark Data Migration is set to Create DTS Migration Task.

      • Different link specifications provide different migration link performance. For more information about how to select a link specification, see Migration link specifications.

      Destination Instance

      Select the destination instance. By default, the system accesses the primary endpoint of the destination instance.

      Note

      This parameter is required when Benchmark Data Migration is set to Data Migration Completed, Enter DTS Task ID, or Create DTS Migration Task.

      Privileged Account of Destination Instance

      The username and password of the privileged account for the destination instance.

      Note

      This parameter is required when Benchmark Data Migration is set to Data Migration Completed, Enter DTS Task ID, or Create DTS Migration Task.

      Privileged Account of Source Instance

      The username and password of the privileged account for the source instance.

      Note

      This parameter is required when Benchmark Data Migration is set to Restore by Backup or Create DTS Migration Task.

    4. In the Stress Testing Basic Settings section, set the following parameters.

      Configuration

      Description

      Select Playback Traffic

      Select the time range for traffic playback.

      Note

      The SQL Explorer and Audit feature must be enabled for the source instance during this time range.

      Playback Speed

      The rate at which source instance traffic is replayed on the destination instance. For example, a value of 1 indicates the original speed. The playback rate must be a positive integer from 1 to 10.

      Note

      If the playback speed that you set exceeds the maximum speed supported by the destination instance type, the stress testing task runs at the maximum supported speed.

    5. In the Advanced Settings section, select an ECS that Deploys Stress Testing Program.

      • You can select DAS Automatic Purchase and Deployment. The system then purchases a pay-as-you-go ECS instance of a suitable instance type based on the QPS of the source instance and the playback speed multiplier.

      • You can also click Add to select an existing ECS instance, generate the deployment command, and run it on that instance.

  5. Click Next.

  6. After the verification is successful, click OK to create the stress testing task.

View results

  1. After the stress testing task is created, return to the task list page to view the task details.

  2. In the Actions column, you can perform the following operations:

    • Click Details to go to the Basic Task Information page to view the execution status and report of the stress testing task.

    • To terminate the stress testing task early, click Terminate.

    • Click Delete to delete the stress testing task that you created.

    • In the Basic Task Information > Parameter Configuration section, you can dynamically adjust the parameters during task execution. The following table describes the parameters.

      Parameter

      Description

      Threads

      The number of playback threads. This value is automatically calculated based on the playback host's CPU: max(3, 2*runtime.NumCPU()-5).

      BatchSize

      The batch size for parsing. SQL statements are processed in batches during parsing. If an out-of-memory error occurs, you can adjust this parameter. Default value: 100000.

      Debug

      Specifies whether to output debug logs.

      ConnectPoolSize

      The size of the connection pool.

      ConnectTimeout

      The connection timeout period. Unit: seconds. Default value: 3.

      SocketTimeout

      The execution timeout period. Unit: seconds. Default value: 10.

      SkipDuplicateErrorSql

      If enabled, the system skips SQL statement templates that cause repeated execution failures or timeouts.

      SqlCountLimit

      The thread dispersal size. A smaller value reduces thread merging but can cause high read pressure, leading to timeouts and affecting playback progress.

Next steps

  • After the stress testing task is complete, go to the Intelligent Stress Testing Details page. If no further tests are needed, release the corresponding ECS and database instances to avoid unnecessary charges.

  • If you manually enabled SQL Explorer and Audit for the source instance, disable it after the stress test is complete. For more information, see Disable SQL Explorer and Audit.

  • If you need to scale out your database instance for an upcoming short-term business peak, you can enable automatic performance scaling or scheduled Auto Scaling based on the instance type.

Related documents

FAQ and error codes for traffic playback