Testing environments should mimic production as closely as possible. However, simply copying production data into test environments can be too static, leading to unrealistic test conditions. Realistic testing requires an endless stream of API calls with production-like timings.
A solution to this challenge is traffic shadowing, where API traffic from production is mirrored to other environments, such as test and QA. This allows test environments to receive the same traffic as production, ensuring that they are continuously and dynamically tested.
By using the shadowing plugin in Membrane API Gateway, you can divert API traffic from production to additional environments without affecting the main production flow. The production traffic is routed as usual, while identical copies of the requests are sent to test and QA environments. Only the response from the production environment is returned to the client, ensuring that test and QA responses do not interfere with production.
<api port="2000">
<shadowing>
<target host="backend.test" port="8080"/>
<target host="backend.qa" port="8080"/>
</shadowing>
<target url="https://backend.prod"/>
</api>
Explanation:
backend.prod
, and its response is returned to the client.<shadowing>
element is used to define additional environments where the traffic will be mirrored. In this case, the API traffic is also sent to backend.test
and backend.qa
. The responses from these environments are ignored.