SDSystem DesignConcepts to case studies
System DesignDSA
x
0/311
Part 1: Foundations
Part 2: APIs and Communication
Part 3: Caching
Part 4: Data and Storage
Part 5: Architecture
Part 6: Distributed Systems
Part 7: Advanced Data Topics
Part 8: Operations and Security
  • Deployment Strategies Overview
  • CI/CD Pipelines
  • Rolling Deployments
  • Blue-Green Deployments
  • Canary Releases
  • Feature Flags
  • A/B Testing Infrastructure
  • Schema Migrations
  • Rollbacks and Immutable Infrastructure
  • Multi-Region and Active-Active
  • Infrastructure as Code (Terraform)
  • Auto-Scaling Policies
  • Zero-Downtime Deployment
  • Chaos Engineering
  • Shadow Traffic and Dark Launches
Part 9: Estimation and Interview Method
Part 10: Case Studies
System Design/Operations and Security/Deployment Patterns

Shadow Traffic and Dark Launches

Try new code with real traffic and no user impact, by copying requests or hiding the feature.

โฑ 12 min readAdvancedHas visualizer
SummaryConceptReal-Life ExampleWhy?Where?How It WorksStepsKey TermsPros & ConsMistakesReal WorldRead NextInterview Q&ACheat-Sheet

01Quick Summary

Shadow traffic copies real production requests to a new version of a service, and throws the new version's answers away. A dark launch ships new code or a new feature to production, but keeps it hidden from users. Both let you test with real conditions and no user impact.

  • Shadow (mirror) traffic: users always get the old version's answer. The new version runs on a copy, and you compare the two.
  • Dark launch: the code is live, but users cannot see or use it, or its results are not shown.
  • The big risk: side effects. A copied "charge the card" request must never charge the card twice.

02Concept: What is it?

Tests with made-up data miss what real traffic does: odd inputs, weird sequences, huge spikes. A canary release shows the new version to real users, which finds problems, but some users are hurt while you learn. Shadow traffic and dark launches try to learn first and expose nobody.

Shadow traffic (also called traffic mirroring or replay): the proxy or gateway sends each request to the current version (v1) and also sends a copy to v2. The user receives v1's response. v2's response is only compared with v1's and logged, then dropped. You look for different answers, errors and slower responses.

Mirroring a request
๐Ÿง‘User
โ†’โ†“request
๐Ÿ”€Proxycopies the request
โ†’โ†“real path
โœ…v1answers the user
๐Ÿ”€Proxythe copy
โ‡ขโ‡ฃshadow, fire and forget
๐Ÿงชv2answer is compared, then dropped
The user is never waiting on v2, and never sees its answer.

Dark launch is a wider idea. You deploy the new code or feature to production, but hide it behind a flag, so no user can see it. You then use it quietly: run it on internal users first, call it in the background and compare its results, or double-write to a new database while still reading from the old one.

๐Ÿง Shadow is not canary
A canary sends real users to the new version. Shadow traffic sends only a copy. Use shadow first to find wrong answers, then a canary to check real behaviour under real users.

03Real-Life Example

๐ŸตThe Understudy in the Wings
A theatre trains a new actor for a lead role. For weeks, the understudy stands in the wings and says every line along with the real actor, but the audience hears only the star. After each show, the director compares the two performances and notes where the understudy would have gone wrong. Only when the understudy has nothing left to fix do they step on stage. The understudy is the new version, and the audience never knew.
Theatre
Shadow traffic and dark launch
The star on stage
v1, answering real users
The understudy in the wings
v2, getting a copy of each request
The audience hears only the star
Users get only v1โ€™s response
The directorโ€™s notes after the show
Diff of v1 and v2 responses
The understudy must not take a bow
v2 must not change real data or send real messages
Rehearsing with a real show
Testing with real production traffic
Stepping on stage at last
A canary release or full rollout

04Why Do We Need It?

๐Ÿ›ก๏ธZero user impact
A bug in v2 cannot reach users, because they never see its answer.
๐ŸŒReal traffic
Real requests include weird cases that test data never covers.
๐Ÿ”ฌExact comparison
You can diff v1 and v2 answers for the same request, and measure the latency gap.
๐Ÿ“ˆLoad check
See how v2 behaves at real volume before it takes real users.
๐ŸงณSafe migrations
Move to a new database, rewrite or search engine, and prove it matches the old one first.
๐Ÿ˜ŒConfidence
By the time you flip the switch, the new version has already run on weeks of real traffic.
Shadow traffic and dark launches let you test with the real world while nobody is watching.

05Where Do We Use It?

โœ๏ธRewrites
A service rewritten in a new language runs in the shadows until its answers match the old one.
๐Ÿ—„๏ธDatabase migrations
Double-write to the new store, read from both, and compare, before switching reads.
๐Ÿ”ŽSearch and ranking
A new ranking model scores real queries, and the results are compared offline.
๐ŸงฎPricing and risk engines
Run a new calculation beside the old one and look at every difference.
๐ŸŒฟStrangler fig migrations
Mirror traffic to the new piece before routing any real users to it.
๐ŸงญNew infrastructure
Try a new cluster, region or cache at real volume with no risk.

06Types / Parts / How It Works

Four related techniques

TechniqueWho sees the new version?What you learnRisk to users
Shadow / mirror trafficNobody. A copy runs and is droppedDifferent answers, errors, latencyNone, if side effects are blocked
Dark launch (hidden feature)Nobody, or only staffWhether the code works in productionVery low
Dark reads and writesNobody. Extra reads or writes go to a new storeWhether the new store matches the oldLow, if the old store stays the source of truth
Canary releaseA small slice of real usersHow real users and metrics reactSome users could be hurt

How a response is checked

Comparing v1 and v2
Ignore (noise)
๐Ÿ•Timestamps, IDs
๐Ÿ”€Random ordering
Investigate (bugs)
๐Ÿ’ฒDifferent price or total
โ›”Error in v2 only
๐ŸขMuch slower in v2
Some differences are expected noise, and some are real bugs.
Expected difference Real difference Performance
VisualizerMirror requests to version 2 and see what you catchRaise the share of mirrored requests to find the three hidden problems. Then set side effects to โ€œRealโ€ and watch customers get double charges. Compare with a canary, where real users see the wrong answers.
How do we try version 2?
Version 2 side effects
Ten requests from real users, in order
  • GET /product/1v1 answers user + copy to v2
  • GET /search?q=shoesv1 answers user
  • POST /ordersv1 answers user + copy to v2side effect blocked in sandbox
  • GET /cartv1 answers user + copy to v2
  • POST /receipt-emailv1 answers user
  • GET /product/7v1 answers user + copy to v2Caught: v2 gives price rounded differently.
  • POST /paymentsv1 answers user + copy to v2side effect blocked in sandbox
  • GET /profilev1 answers user
  • GET /feedv1 answers user
  • POST /ordersv1 answers user + copy to v2side effect blocked in sandbox
Requests copied to v2
6
answers discarded
Differences caught
1
of 3 hidden problems
Duplicate side effects
0
real customers affected
Wrong answers seen
0
by real users
Extra load
+60%
on v2 and the network
Shadow traffic found 1 of the 3 known problems and no user saw anything wrong. Version 2 answered real requests, and its answers were thrown away after the comparison.

A fixed list of ten requests, so the same settings always tell the same story. Real tools (Envoy or Istio mirroring, GoReplay) copy live traffic and compare responses automatically.

07How to Use It / Steps / Implementation

Doing it safely

  1. 1
    Copy requests at the edge
    Use a proxy, gateway or service mesh with a mirror option (Envoy and Istio can do it), or a replay tool such as GoReplay.
  2. 2
    Fire and forget
    Never make the user wait for v2. A slow or crashing v2 must not slow v1.
  3. 3
    Block side effects
    Point v2 at a sandbox: a copy of the database, a fake payment provider, an email black hole. Or mark mirrored calls so writes are skipped.
  4. 4
    Handle private data
    A copy of a request has the same personal data. Apply the same security, retention and masking rules.
  5. 5
    Compare automatically
    Store both answers, normalise noise (times, IDs, order), and count real differences.
  6. 6
    Watch the load
    Mirroring can double traffic to shared dependencies. Mirror only a share, and use quotas.
  7. 7
    Fix, repeat, then graduate
    When differences are explained, move to a canary release and then a full rollout.
๐Ÿ’กDark launch with a flag
Hide the feature behind a feature flag that is off for everyone, then switch it on for staff only. Their real use finds problems in production before any customer sees it.
โš ๏ธReads are easy, writes are not
Mirroring read-only requests is simple. Mirroring a POST /payments without stubbing the effect can charge a customer twice.

08Key Terms to Know

TermMeaning in easy words
Shadow trafficA copy of real requests sent to a new version, with its answers dropped
Traffic mirroringAnother name for shadow traffic, used by proxies and meshes
Traffic replayRecording real requests and sending them later to another system
Dark launchReleasing code or a feature to production while hiding it from users
Dark read / dark writeReading from or writing to a new system in the background, and comparing
Double writeWriting every change to both the old and the new store during a migration
Response diffA comparison of the old and new answers for the same request
Side effectAnything that changes the outside world, such as a charge, email or database write
IdempotentSafe to run more than once with the same result
NoiseDifferences that do not matter, such as timestamps and random IDs
Source of truthThe one system whose data counts. Stays on the old side until you switch

09Pros, Cons and Trade-offs

โœ… Pros
  • Real traffic with no user impact
  • Finds wrong answers, not just crashes
  • Shows performance at real volume
  • Builds proof before a migration
  • Easy to turn off
โš ๏ธ Cons
  • Side effects need careful blocking
  • Doubles load on shared systems
  • Copies of private data need protection
  • Diffing is noisy and takes effort
  • Cannot show how real users react

Trade-offs

ChoiceWe gainWe lose
Mirror 100% of trafficComplete coverageDouble load, double risk of leaks
Mirror a sampleCheaper and saferRare cases may be missed
Stub side effectsNo duplicatesv2โ€™s write path is not fully tested
Sandbox copy of the dataA realistic, safe testCost, and the copy goes stale
Shadow before canaryFewer surprises for usersSlower rollout

10Common Problems and Mistakes

Common mistakes

  1. Real side effects in v2. Duplicate charges, emails and orders. The classic disaster.
  2. Making users wait for the mirror. The copy must be asynchronous, with its own timeout.
  3. Overloading shared dependencies. The shadow service and the real one hit the same database.
  4. Leaking personal data. Mirrored requests land in logs, test systems or third parties.
  5. Diffing raw responses. Without ignoring timestamps and IDs, every request looks different.
  6. Different data. v2 reads a stale copy, so differences are not bugs in the code.
  7. Skipping the canary. Shadow traffic does not tell you how real users behave with the new version.

Things to watch

๐Ÿ”Authentication
Mirrored calls may carry user credentials. Decide what v2 is allowed to do with them.
๐Ÿ•ฐ๏ธOrdering
Requests that depend on earlier writes may behave differently in a copy.
๐ŸŽฒNon-determinism
Random values, current time and ranking ties cause diffs that are not bugs.
๐ŸงนCleanup
Remove the mirror, the flag and the double write once the migration is done.

11Real-World Examples

๐ŸงฐEnvoy and Istio
Have request mirroring built in, with a configurable share of traffic.
๐Ÿ”GoReplay
An open source tool that records live HTTP traffic and replays it against another environment.
๐Ÿ™GitHub Scientist
A library that runs the old and new code paths side by side and reports mismatches. Used for risky refactors.
๐Ÿ“˜Facebook and others
Companies commonly use dark launches to test big features on staff and a hidden share of traffic before announcing them.
๐Ÿ—„๏ธDatabase migrations
Many teams double-write to a new store and compare reads before cutting over.
๐ŸฆPayments and risk
New fraud or pricing models often run in shadow mode, scoring real transactions without acting on them.
Mini case: moving to a new database
โœ๏ธDouble writeold is the truth
โ†’โ†“
๐Ÿ”Shadow readscompare, drop new answer
โ†’โ†“
๐ŸคCanary reads1% from new
โ†’โ†“
๐ŸSwitchnew is the truth
Four stages, and only the last one is visible to users.

12Related Topics to Read Next

Canary Releasesโ†’

The next step: a small share of real users.

Feature Flagsโ†’

The switch that keeps a dark launch hidden.

Strangler Figโ†’

Mirror traffic to the new piece before routing users to it.

A/B Testing Infrastructureโ†’

Showing different versions to users, not hiding them.

Deployment Strategies Overviewโ†’

Where shadow and dark launches fit on the map.

Idempotencyโ†’

Why repeated requests must be safe, and what to do when they are not.

Schema Migrationsโ†’

Dark reads and writes are a common way to move data safely.

13Interview Questions with Short Answers

14Quick Revision Cheat-Sheet

  • โœ”Shadow traffic: copy requests to v2, drop its answers, compare.
  • โœ”Dark launch: ship the code, hide the feature.
  • โœ”Dark writes: write to the new store too, but keep the old as the truth.
  • โœ”Biggest risk: side effects. Stub payments, emails and writes.
  • โœ”Keep it async: the user never waits for v2.
  • โœ”Also watch: double load, private data, noisy diffs.
  • โœ”Order: shadow, then canary, then full rollout.
  • โœ”One line: โ€œRehearse with the real show, and let nobody hear the understudy.โ€
โ† Previous
Chaos Engineering
Next โ†’
Three Pillars of Observability