Traffic Mirroring & Replay

Mirror production traffic to staging, replay requests against new versions.

Traffic Mirroring

Mirror 100% of production traffic to a shadow service. The shadow processes requests but its responses are discarded — production traffic is unaffected.

rf traffic mirror api --from production --to staging
✓ Traffic mirroring active
  Source: api (production, v43)
  Shadow: api (staging, v44)

  Production traffic is being copied to staging in real-time.
  Shadow responses are discarded — no impact on users.

  Stop with: rf traffic mirror stop api

Use Cases

  • Load testing with real traffic — see how a new version handles actual production load
  • Pre-deploy validation — deploy to staging, mirror traffic, compare error rates before promoting
  • Performance benchmarking — compare latency between current and candidate versions

Compare Results

rf traffic mirror stats api
TRAFFIC MIRROR STATS (last 1h)
──────────────────────────────
                Production (v43)    Shadow (v44)
Requests:       45,230              45,230
Success rate:   99.88%              99.91%
P50 latency:    22ms                19ms
P99 latency:    145ms               128ms
Errors:         54                  41

Shadow is performing 11% faster with fewer errors.

Mirror Configuration

traffic:
  mirror:
    source: production
    target: staging
    sample_rate: 100      # Percentage of traffic to mirror (1-100)
    timeout: 5s           # Max time to wait for shadow response
    compare_responses: true  # Log response differences

Traffic Replay

Capture a window of production traffic and replay it against any environment.

Capture Traffic

rf traffic capture api --duration 30m --output capture-march-16.rfcap
✓ Capturing traffic on api (production)
  Duration: 30 minutes
  Started: 2026-03-16T14:00:00Z

  Capturing... 12,847 requests captured
✓ Saved: capture-march-16.rfcap (24MB)

Replay Traffic

rf traffic replay capture-march-16.rfcap --target staging --speed 2x
Replaying 12,847 requests against api (staging) at 2x speed...

Progress: ████████████████████ 100% (15 minutes at 2x)

RESULTS
  Requests:     12,847
  Success:      12,803 (99.66%)
  Failed:       44 (0.34%)
  Avg latency:  28ms (production was 24ms)

  Response diff: 23 responses differed from production
  View diffs: rf traffic replay diff capture-march-16.rfcap

Compare Responses

rf traffic replay diff capture-march-16.rfcap --show 5
DIFF 1/23 — GET /api/users/u_123
  Production: 200 {"name":"Alice","plan":"pro"}
  Staging:    200 {"name":"Alice","plan":"pro","avatar":null}
  Difference: New field "avatar" in staging response

DIFF 2/23 — POST /api/orders
  Production: 201 {"id":"o_456"}
  Staging:    500 {"error":"column 'discount_code' does not exist"}
  ⚠ Schema mismatch — staging migration may be missing

Replay at Scale

Replay at higher throughput to load test:

rf traffic replay capture-march-16.rfcap --target staging --speed 10x --concurrency 100

This replays 30 minutes of traffic in 3 minutes at 10x the original rate with 100 concurrent connections.

Request Inspection

View individual requests hitting your services:

rf requests --service api --status 500 --last 1h
TIME         METHOD  PATH              STATUS  DURATION  SIZE
14:23:12     POST    /api/orders       500     45ms      128B
14:25:01     GET     /api/users/u_999  500     12ms      64B
14:28:33     POST    /api/checkout     500     89ms      256B
# View full request details
rf requests show req_abc123
Request req_abc123
  Time:    2026-03-16T14:23:12Z
  Method:  POST
  Path:    /api/orders
  Status:  500 Internal Server Error
  Duration: 45ms

  Request Headers:
    Content-Type: application/json
    Authorization: Bearer ****
    User-Agent: Mozilla/5.0...

  Request Body:
    {"product_id": "p_123", "quantity": 2}

  Response Body:
    {"error": "column 'discount_code' does not exist"}

  Trace: tr_d4e5f6a7b8c9
  Deployment: dep_f8a3 (v43)