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:
Configure a traffic replication policy
Log on to the Cloud-native API Gateway console.
In the left-side navigation pane, click API. In the top navigation bar, select a region.
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.
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.
NoteOnly HTTP- or HTTPS-based services are supported.
Port
The port of the destination service. You can select Dynamic Port.
NoteDynamic 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.
NoteIf 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 . 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.