All Products
Search
Document Center

API Gateway:Configure a traffic replication policy

Last Updated:Jan 07, 2025

You can configure a traffic replication policy for a route on a Cloud-native API Gateway instance. This way, you can perform simulation tests and fault location on the system by copying traffic of online applications to a specific application. This topic describes how to configure a traffic replication policy on a Cloud-native API Gateway instance.

Background information

Networks are becoming increasingly complex. As a result, simulation of online requests in a test environment becomes more difficult. To resolve this issue, the traffic replication feature is introduced. The traffic replication feature replicates online requests at the traffic ingress and sends the replica to the test environment. This allows you to test some new features or verify defects based on online traffic.

Sample scenarios

In this example, a traffic replication policy is configured for Route1 to copy traffic to Service2. The replication percentage is 100%. The following figure shows the architecture in the sample scenario:

image

Configure a traffic replication policy

  1. Log on to the Cloud-native API Gateway console.

  2. In the left-side navigation pane, click API. In the top navigation bar, select a region.

  3. Click the target API. On the API details page, click the name of the target route. Click the Configure Policy tab and click Mirror Traffic on the left.

  4. Configure the parameters on the right and click Save. The following table describes the parameters:

    Parameter

    Description

    Enable

    Specifies whether to enable the traffic replication policy.

    Destination Service

    The destination service to which you want to forward replicated traffic.

    Note

    Only HTTP- or HTTPS-based services are supported.

    Port

    The port of the destination service. You can select Dynamic Port.

    Note

    Dynamic Port is suitable for scenarios in which service ports dynamically change. You cannot select Dynamic Port for multi-port services.

    Traffic Mirror Percentage (%)

    The traffic replication percentage. Valid values: 0 to 100.

    Note

    If you set this parameter to 50, 50% of the traffic in the current route is replicated to the destination service.

Verify the result

Click the name of the gateway instance that you want to manage. On the page that appears, choose Observation and Analysis > Business Monitoring > Canary Release Comparison Dashboard. View the queries per second (QPS) of Service1 and Service2. In the result, the QPS of Service1 is the same as that of Service2. This indicates that all traffic of Service1 is replicated to Service2.