Skip to content
tezvyn:

Shadow Deployment: Test in Production, Safely

Source: docs.aws.amazon.comHardHow cards are made

Shadow Deployment: Test in Production, Safely

Shadow deployment copies live user traffic to a new "shadow" service for testing without user impact. It's used to validate new code versions with real-world load or to analyze traffic for security threats.

Why it exists

How can you be sure a new service version will handle the chaos of production traffic before you actually send users to it? Staging environments are clean and predictable, but production is messy. Shadow deployment was created to bridge this gap, allowing you to test new code with real, live traffic without any risk to the user experience.

The mental model

Think of shadow deployment as a one-way mirror for your network traffic. Live user requests go to your stable production service, and a silent, identical copy of that traffic is also sent to a new "shadow" service. The shadow service processes the request, but its response is thrown away. The user never knows the shadow exists. You get to observe how the new code behaves under real-world load by monitoring its logs, metrics, and errors.

How it works

At the infrastructure level, a component like a load balancer or service mesh is configured to duplicate incoming requests. One request goes to the primary, production service. The other goes to the shadow service. This process is often called traffic mirroring. The key is that the shadow system is completely out-of-band; its success, failure, or latency has no impact on the user's request to the primary service. The system only cares about the response from the primary service.

When to use it

Use shadow deployment to de-risk major changes. First, for validating a significant refactor or a new version of a service by exposing it to production load before a full cutover. Second, for performance testing a new component against your actual traffic patterns. Third, for feeding traffic to a new security or monitoring appliance to see what it catches without putting it in the critical path and adding latency.

When not to use it

Do not use shadow deployment for A/B testing, as the user never sees the result from the shadow. Most importantly, never use it if the shadow service has side effects. If a request to your shadow service could write to a production database, update a user's record, or send an email, you will cause serious data corruption and bugs. Shadowed requests must be read-only or write only to a separate, isolated data store.

One canonical example

AWS VPC Traffic Mirroring lets you copy network traffic from a source, like an EC2 instance's network interface. You can create a session to mirror traffic from your production API servers (the source) to a new set of servers running a release candidate (the target). You can apply filters to only mirror traffic for specific endpoints, like POST requests to /api/v2. Your production users are served by the old servers, while the new servers are secretly tested against the exact same traffic, letting you find bugs before a real launch.

Interview question

Under which scenario would shadow deployment be an inappropriate choice?

  • a.Testing a new security appliance's effectiveness by feeding it real network traffic.
  • b.Validating a new service version's stability under peak production load.
  • c.Comparing two different UI designs to see which users prefer.Correct
  • d.Assessing the performance impact of a database schema change with live traffic.
Why?

Shadow deployment is explicitly stated as not suitable for A/B testing, as the user never sees the result from the shadow service. The other options describe valid applications of shadow deployment for testing stability, performance, or security with real traffic without user impact.

Just read this? Test yourself on what you have been reading.

Read the original → docs.aws.amazon.com

You just looked this up. Could you explain it out loud?

That is the part interviews actually test. Tezvyn takes questions like this one and gives you what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Open roles that interview on sre — each one lists the topics its interview covers.

See open roles