Stackbook Logo
traffic-managementestablished · medium operational burden

Shadow Traffic

Also known as: traffic-mirroring, dark-launch, request-shadowing

Intent

Copy live production requests to a new version whose responses are discarded, validating behaviour and performance with zero user impact.

Problem

Synthetic tests and staging load never match the shape, volume and strangeness of real traffic. Yet exposing a rewrite or new dependency to users to find out is too risky.

Forces

  • •Real traffic exposes edge cases tests miss
  • •Users must not see results from the unproven version
  • •Duplicated requests can cause duplicate side effects
  • •Mirroring adds load and cost

Solution

Overview

Shadow traffic, also called mirroring or dark launching, sends a duplicate of production requests to a candidate version. Users are served only by the current version, so a defective candidate costs nothing but compute.

How it works

The proxy tee's each request. The primary response goes back to the client; the mirror is fire-and-forget.

client --> proxy --> stable v1 --> response to client
              |
              +--(copy, async)--> candidate v2 --> discarded
                                        |
                                  diff + metrics store

In Envoy or Istio this is a mirror policy with a sample percentage. A comparison job normalises volatile fields, such as timestamps and generated ids, then reports mismatch rates and latency percentiles.

Pitfalls

  • Mirroring writes. Candidate must run with a sandboxed database, dry-run mode or stubs for third-party calls.
  • Forwarding authentication tokens or personal data to environments with weaker controls.
  • Synchronous mirroring, which makes the primary wait for the shadow.
  • Comparing without normalisation, producing thousands of false diffs.
  • Forgetting that the shadow stack needs production-scale capacity to be a valid load test.
  • Starting at 100 percent; ramp the sample rate gradually.

Key takeaways

  • Mirror requests, discard responses, compare results.
  • Isolate every side effect before mirroring.
  • Keep mirroring asynchronous and sampled.
  • Normalise nondeterminism in comparisons.
  • Treat it as validation before a canary, not a replacement for one.

✓ When to Use

  • •Rewrites, migrations and replacement of a critical dependency
  • •Capacity validation of new infrastructure under real load
  • •Comparing outputs of a new algorithm against the incumbent

✗ When Not to Use

  • •Requests with non-idempotent side effects you cannot isolate, such as payments and emails
  • •Privacy-restricted data that may not leave the production boundary
  • •When capacity cannot absorb the duplicated load

Pros

  • +Zero user-facing risk
  • +Tests with true production distribution
  • +Finds performance regressions before release

Cons

  • −Doubles load on mirrored paths
  • −Hard to handle stateful or side-effecting requests
  • −Result comparison needs tooling

Cost Profile

Infrastructure

High - capacity for a second stack

Operational

Medium - diff pipeline and data hygiene

Cognitive

Medium - reasoning about isolation of side effects

Failure Modes

  • Shadow writes pollute production data or send real notifications

  • Mirroring slows the primary path if not asynchronous

  • Nondeterministic fields cause noisy diffs that hide real regressions

Real-World Examples

Alternatives

  • canary-deployment

Related Patterns

  • progressive-delivery
  • service-mesh
  • api-gateway

Competency Domains

reliability opsdistribution communication