Open Source API Gateway

Traffic Shadowing with Membrane API Gateway

Overview

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.

Solution

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.

Configuration

<api port="2000">
<shadowing>
<target host="backend.test" port="8080"/>
<target host="backend.qa" port="8080"/>
</shadowing>
<target url="https://backend.prod"/>
</api>
<api port="2000">
    <shadowing>
        <target host="backend.test" port="8080"/>
        <target host="backend.qa" port="8080"/>
    </shadowing>
    <target url="https://backend.prod"/>
</api>
Explanation:
  • Main Production Flow: The primary traffic is routed to backend.prod, and its response is returned to the client.
  • Shadowing Configuration: The <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.

Benefits of Traffic Shadowing

  • Realistic Testing: Test and QA environments receive real production traffic, leading to more accurate test results.
  • Continuous Testing: API calls continuously flow into your test environments, making them more dynamic and closer to real-world conditions.
  • Non-Intrusive: Test and QA environments do not interfere with the actual production flow. Only production responses are returned to clients.