Skip to main content

Module mirror

Module mirror 

Source
Expand description

Traffic mirroring / shadowing middleware.

Sends a copy of traffic to a secondary backend (fire-and-forget, response discarded). Useful for testing new backend versions, benchmarking, or audit recording.

§Configuration

[[backends]]
name = "api"
transport = "http"
url = "http://api.internal:8080"

[[backends]]
name = "api-v2"
transport = "http"
url = "http://api-v2.internal:8080"
mirror_of = "api"        # mirror traffic from "api" backend
mirror_percent = 10      # mirror 10% of requests

§How it works

  1. Request arrives targeting api/search
  2. Primary response is returned from the api backend as normal
  3. A copy of the request is rewritten to api-v2/search and sent fire-and-forget to the api-v2 backend
  4. The mirror response is discarded; errors are logged but don’t affect the primary response

Structs§

MirrorLayer
Tower layer that produces a MirrorService.
MirrorService
Traffic mirroring middleware.