Testing Without Consequences
What if you want to test how your new version handles real production traffic — the actual volume, the actual request shapes, the actual edge cases — but you are not ready to let it serve real users? Rolling, Blue/Green, and Canary all involve real users receiving responses from the new version at some point. Shadow deployment does not.
Shadow Deployment (also called "Dark Launching" or "Traffic Mirroring") works like this:
- Deploy v2 alongside v1.
- When a user makes a request, the router does two things simultaneously:
- Sends the request to v1, which handles it normally and returns the response to the user.
- Sends an exact duplicate copy of the request to v2 "in the shadow."
- v2 processes the request fully, but its response is discarded. The user never sees it, never waits for it.
What Shadow Deployment Is Good For
- Performance testing under real load: You can observe how v2 handles production traffic patterns without synthetic load tests, which often miss real-world edge cases.
- Correctness comparison: You can log both v1 and v2 responses and compare them. If v2 produces different results for the same input, you have found a bug before any user was affected.
- New infrastructure validation: If you are migrating to a new database engine or caching layer, shadow traffic lets you validate the new stack handles real queries correctly.
The Danger of Side Effects
Shadow deployment has one critical constraint: side effects. If the request is "Place Order," and both v1 and v2 process it fully, the customer might be charged twice, receive two confirmation emails, or have two inventory items reserved.
Shadow deployment requires that the shadow instance mocks out all external calls — payment processors, email services, SMS gateways, third-party APIs — so it exercises the application logic without changing the state of the world. This is non-trivial to implement correctly and is why shadow deployment is typically used for read-heavy or analytically complex workloads rather than write-heavy transactional systems.