This topic describes how to mirror production traffic to a staging environment for Application Load Balancer (ALB).
Scenarios
For enterprises that have a high requirement for service security and stability, new features must be tested separately from the production environment before they are released. This prevents service interruptions.
ALB supports traffic mirroring, which can mirror production traffic to backend servers in a staging environment. Meanwhile, ALB automatically drops responses from the backend servers in the staging environment to ensure that the tests do not affect workloads in the production environment. Traffic mirroring is ideal for the following scenarios:
Test new features and service performance.
Replicate production traffic for testing purposes without the need to create additional data.
Reproduce errors for troubleshooting.
Limits
Both Internet-facing ALB instances and internal-facing ALB instances support traffic mirroring.
Basic Edition ALB instances do not support traffic mirroring.
Prerequisites
A server group (Server Group A) is created to process production traffic and another server group (Server Group B) is created to process mirrored traffic. The backend protocol is set to HTTP. For more information, see Create and manage server groups.
A listener is created. For more information, see Add an HTTP listener, Add an HTTPS listener, and Add a QUIC listener.
Mirror network traffic
- Log on to the ALB console.
In the top navigation bar, select the region where the ALB instance resides.
On the Instances page, click the ID of the instance that you want to manage.
On the Listener tab, find the listener that you want to manage and click View/Modify Forwarding Rule in the Actions column.
Choose and click Add Forwarding Rules.
In the Add Forwarding Rules section, set the parameters of the forwarding rule.
In this example, network traffic from the /test path is mirrored to servers in Server Group B.
Action: Set Traffic Mirror to Server Group B and Forward to Server Group A.
ImportantALB drops responses from backend servers in staging environments. Therefore, you must set the Forward To parameter to route network traffic to backend servers in the production environment to prevent service errors.
Click OK. After you complete the configurations, network traffic that is sent to Server Group A can be mirrored to Server Group B.