Testing in production and observability
Staging runs out before your risk does: test in production on purpose, with a blast radius you chose, abort criteria you wrote down first, and telemetry that can tell the new path from the old
An engineering lead proposes sending real production traffic to a rewritten fraud-scoring service before it takes any decisions. Staging tests all pass. What must exist before the first production request reaches the new service?
Testing in production is the deliberate use of the production environment, its real traffic, data, configuration and dependencies, to gain evidence that a change works, under controls that limit the harm if it does not. The controls are the whole difference. Without them it is shipping and hoping.
This chapter is the Lead’s view. Release management and sign-off covers the release checklist, testing flags both ways, guarded rollouts and rollback, and Launches and go-to-market covers rollout cohorts from the product seat. Here the question is larger: across several teams, which risks do you buy down before production and which in it, how do you design a production test so its worst case is acceptable, and what has to be true of your observability before any of it is safe. The artefact is a production test plan with abort criteria and blast-radius limits.
Why staging runs out
Staging is a model of production. Like any model, it is useful where it is faithful and misleading where it is not, and the places it is not faithful are predictable.
- Data. Staging has thousands of rows of tidy test data. Production has years of data written by every version of the code that ever ran, including the one with the bug that stored dates as strings for three weeks in 2021.
- Traffic shape. Your load test models the traffic you know about. Production has the retrying client, the merchant who sends every payment twice, the bot, and the mix that changes at month end.
- Configuration. Feature flags, secrets, timeouts, quotas and DNS differ between environments, and a config difference is a code difference you never tested.
- Dependencies. Staging talks to sandboxes. A payment provider’s sandbox accepts every card and never times out the way the live endpoint does on a Friday afternoon.
- Scale and time. Caches, connection pools, clock skew, certificate expiry and the job that runs at 02:00 on the first of the month do not appear in an afternoon of staging tests.
Each gap can be narrowed with money: copy anonymised data, replay traffic, mirror config, build better fakes. Each costs engineering time to build and more to keep current, and returns diminish. The first staging environment catches a lot. The second, more faithful one catches less per pound spent, and it drifts from production the week after you finish it. At some point the cheapest place to learn how a change behaves in production is production, carefully.
The careful part matters. Testing in production does not replace the earlier levels of the test strategy. Unit, contract and integration tests still catch the bugs that are cheap to catch early; the test strategy chapter still decides what each level is for. Production testing is an additional level with its own job: finding the faults that only production’s data, traffic and dependencies can show.
The three phases
Cindy Sridharan’s essay “Testing in Production, the safe way”, in the reading, divides production testing by how much the change is exposed. The division is the most useful model a Lead can carry, because each phase has different tools and a different worst case.
| Phase | The change is | Techniques | What it catches | Worst case if it goes wrong |
|---|---|---|---|---|
| Deploy | running in production, serving no user | shadow traffic, tap compare, integration checks against real dependencies, config tests | behaviour differences on real inputs, real dependency quirks, config errors | side effects of shadowed writes; load on shared dependencies |
| Release | serving a slice of users | canaries, flag cohorts, traffic shifting, automated rollback | errors and latency that only real users trigger | the slice gets a broken experience until abort |
| Post-release | serving everyone | synthetic checks, feature flags, dark launches, fault injection, observability | regressions over time, rare paths, degradation paths that never run | an incident, with detection as your only defence |
Read the table from left to right as a ladder of exposure. A good plan moves a risky change up it one rung at a time and writes down what evidence moves it to the next. Most teams skip the deploy phase entirely and go straight to a canary, which means the first real request the new code ever sees is a customer’s.
Blast radius is the first design decision
Before you choose a technique, decide what the test is allowed to reach. Blast radius is the set of users, data, money and systems a failure could touch. It has more dimensions than the percentage on a rollout slider.
- Who. Internal staff, a test tenant, friendly customers, a percentage of accounts, a region. Choose cohorts you can name and contact, not a random 1% you cannot find afterwards.
- What it can write. Reads are cheap to test in production. Writes, payments, messages and notifications are not, because they leave the test.
- How much money. For payment paths, cap the value: transactions under a limit, a daily total, test cards on the live network where the scheme allows them.
- Which systems. A shadowed service that calls a shared database can take down the old path too. Count the dependencies the test will load.
- How long. A test with no end date becomes the new production by drift. Give it an end.
The rule of thumb Leads use: the blast radius should be small enough that the worst case is something you would explain in an incident review without embarrassment. If the worst case needs a regulator notified, the radius is too large or the test belongs elsewhere.
Writes deserve their own paragraph. A test that replays or duplicates requests is safe only for operations that are safe to repeat. The idempotency lesson explains why, and why most payment bugs live here. Where an operation is not idempotent, the plan must say how the test is kept from performing it: a write-suppressing mode, a sandbox credential, a test-tenant filter, or not testing that path in production at all.
Abort criteria, written before you start
An abort criterion is a signal, a threshold and an action, agreed before the test begins. “We’ll watch the dashboards” is not one. Without it, every result at 02:00 becomes a negotiation, and the person who wants the release to succeed is usually the person on call.
A usable abort criterion has five parts:
- The signal, measured on the test population only: error rate of the canary, mismatch rate of the shadow, success rate of the synthetic check.
- The comparison. Against a baseline running the old version on the same traffic at the same time, not against yesterday. Traffic, dependencies and time of day all move the numbers.
- The threshold and the minimum sample. A 2% error rate on forty requests is noise. Say how many requests or minutes you need before the threshold means anything.
- The action. Flag off, route back, stop the mirror. Automatic where the signal is unambiguous; human where it is not, with a named person.
- Time to stop. How long from the threshold being crossed to the blast radius being zero. Measure it in rehearsal. If the flag takes four minutes to propagate, the plan says four minutes.
Tie the thresholds to the service’s error budget where it has one. SLIs, SLOs and error budgets explains the budget, and burn-rate alerts explains how to turn a budget into a signal that fires fast on a sharp regression without paging on noise. A production test that could burn a week of budget in an hour needs a tighter radius or a faster abort.
Add one criterion that is not a metric: the stop word. Anyone on the team, including support, can halt the test by saying so in the channel, without having to prove it.
Shadow traffic and tap compare
Shadowing, or mirroring, sends a copy of real requests to the new code alongside the old. The old code’s response goes to the user. The new code’s response is compared and thrown away. Tap compare is the comparison step. It is the strongest pre-release evidence there is for a rewrite or a migration, because the inputs are exactly the inputs production sees.
GitHub’s Scientist library, in the reading, is the pattern at code level: wrap the old and new implementations in an experiment, return the old result, record mismatches and timings. Service meshes such as Istio and Envoy can mirror at the network level, and Twitter’s Diffy compared whole service responses. The tools are mature. The hard parts are test design.
- Side effects. A shadowed request that writes, charges or sends is a real write, charge or send. Shadow reads freely. For writes, run the new path in a mode that computes but does not commit, or point it at an isolated store.
- Noise. Timestamps, generated ids and ordering differ on every run. Normalise them before comparing, or the mismatch rate tells you nothing. Run the old code against itself first: the mismatch rate between two copies of the same version is your noise floor.
- Load. Shadowing doubles the requests on whatever the new path calls. Sample, and check the shared dependencies have the headroom.
- Privacy. Mirrored traffic contains real personal data. It goes only to systems with the same controls as production.
The mismatch rate is the abort signal and the exit criterion at once. You do not move to a canary until mismatches are explained or under an agreed rate, and every unexplained category has a ticket.
Canaries and cohorts, from the quality seat
The mechanics of canaries, guarded rollouts and flags are in the release chapter. The Lead’s contribution is the test design inside them.
A canary is an experiment with a control group. Treat it as one. The canary and the baseline must receive comparable traffic, so the canary should not be the one node that only serves health checks. The metrics you compare must be ones a broken change would move: if the new code returns a wrong amount with HTTP 200, error rate and latency will not see it, and you need a correctness signal, such as a reconciliation count or a business metric segmented by version. The Google SRE workbook chapter on canarying, in the reading, is the best treatment of choosing those metrics and sizing the canary.
Ask of every canary metric: if the feature were broken in the way we fear most, would this number move within the canary window? If not, it is not evidence.
Synthetic checks are your regression suite in production
A synthetic check is a scripted request or journey run against production on a schedule. The synthetic monitoring chapter covers how probes work, where to run them and the side effects of synthetic traffic. From the quality seat, the point is ownership: the journeys your end-to-end suite tests before release are the journeys a synthetic check should test after it.
Pick the five to ten journeys whose failure would be an incident: sign in, pay, receive a message, export a statement. Run them against production every minute or few minutes from outside your network, with test accounts whose effects are filtered from reports and whose payments go to a sandbox or a test card. When a release ships, the synthetic checks are the first post-release evidence, and they keep running at 04:00 when nobody is using the product and the white-box metrics have nothing to say. A journey without a synthetic check is a journey you will hear about from a customer.
Observability is the test oracle
Every test needs an oracle: a way to tell pass from fail. Before release, the oracle is an assertion. In production, the oracle is your telemetry, and a production test is only as good as your ability to ask it a question.
The question you need to ask is always comparative: is the new version, for these users, behaving differently from the old? That needs every event to carry the build version, the flag states and the cohort, so you can group by them. Wide events explains why one rich event per request with those fields answers the question in one query, where three separate dashboards do not. Before you approve a production test plan, ask the team to show you the query that would separate the test population from the rest. If they cannot write it, the test cannot fail visibly, and a test that cannot fail is not a test.
Observability also lets you test the paths that never run. Fallbacks, graceful degradation, load shedding and circuit breakers are code that runs only when something else fails, which means they are usually untested until the incident. Fault injection in production, starting small and on a known cohort, is how you find out whether the fallback works. The Principles of Chaos Engineering, in the reading, set the rules: state a hypothesis about steady state first, minimise the blast radius, and have a way to stop.
Where practitioners disagree
Staging or production. One camp, Majors the loudest, argues that staging is expensive theatre and the investment belongs in production safety: flags, canaries, observability, fast rollback. The other points out that a payment gateway, a medical device or a bank cannot treat customers as a test cohort, and that some regulators expect evidence from a controlled environment. Both are right about their systems. The Lead’s job is to decide per risk, not per ideology: what does staging fail to show for this change, what would it cost to make it show that, and what would it cost to learn it in production under controls.
Who owns it. Some teams see production testing as an SRE practice and QA as pre-production. That split leaves the test design to people who are not test designers. The better split is QA designs the experiment and the oracle, SRE owns the platform and the abort mechanism, and the service team runs it.
How much to automate the abort. Automatic rollback on clear signals is fast and does not get tired. On ambiguous signals it flaps. Automate the unambiguous ones and keep a human for the rest.
What you never test in production
Some effects cannot be undone: money sent to an external bank, messages delivered to a phone, emails to a regulator, data deleted without a backup. Some data must not be touched by test code at all. And some changes cannot be observed well enough to know whether they failed. For these, production testing is the wrong tool, and the right answer is better pre-production fidelity: a faithful copy of the dependency, a contract test against the provider, or a rehearsal with the provider’s certification environment. Write the exclusions into the plan so nobody discovers them during the test.
Day to day
As a Lead, you rarely run the production test yourself. You set the practice and review the plans.
Weekly, in the release or change review. You read the risky changes coming up across your teams and ask of each: what evidence will exist before it reaches users, and which of it will come from production? Changes that rewrite a money path, migrate a store or swap a provider get a production test plan. Fifteen minutes per plan, with the engineer who wrote it.
Before each production test. You review the plan against the rubric: blast radius named, abort criteria with baselines and minimum samples, stop mechanism timed in rehearsal, oracle query written, exclusions listed. You check that support and on-call know a test is running and who has the stop word.
During a shadow or canary phase. A short daily look at the mismatch report or canary comparison with the owning engineer. Each unexplained mismatch category gets a ticket and an owner. The phase advances when the exit criteria in the plan are met, not when the calendar says so.
Monthly. You review the synthetic check catalogue against the critical journeys: is every journey covered, has any check gone flaky, is any check passing while the journey is broken? You look at which incidents in the last month were caught by a production test, a synthetic check or a customer, and you bring that to the quality metrics review.
Quarterly. You run or sponsor a game day: inject a fault on a known cohort, confirm the degradation path works and the alerts fire. You review the staging budget with the engineering managers and decide where the next pound of fidelity goes, and where production testing replaces it.
You test in production whether you call it that or not, because there is no staging worth the name. Make it deliberate with three cheap things: a feature-flag service so new paths ship dark, a handful of synthetic checks on sign-up and payment from a hosted probe service, and a single structured log line per request carrying the build version. Write the abort criterion in the pull request description. Test money paths with the provider’s live test cards and a low value cap. Nobody will write a formal plan; a ten-line checklist in the repository is enough.
Staging exists and drifts. Several teams ship daily, and incidents start to come from changes that passed every test. This is where you introduce the production test plan as a required document for risky changes, agree with SRE who owns the canary and mirroring platform, and get version and flag fields onto every event. Expect pushback from teams who see it as paperwork; answer with the last incident that a shadow phase would have caught. The staging-versus-production budget argument happens here for the first time, and you should bring numbers to it.
The tooling exists: progressive delivery, mirroring in the mesh, a synthetic monitoring vendor. The problem is consistency and permission. Some business units forbid production testing by policy written years ago; others do it with no controls. Your work is a standard for production tests that risk, compliance and audit can approve once, with the blast-radius and data rules built in, so teams do not negotiate each test from scratch. Expect change-advisory boards to want evidence; give them the plan and the abort record, which is better evidence than a staging sign-off.
Template
# Production test plan: <change>
Owner · QA lead · SRE contact · Date · Status: draft | approved | running | complete | aborted
## Why production
What staging cannot show for this change: <data, traffic, config, dependency, scale>
## Phases
| Phase | Technique | Blast radius (who / writes / money / systems / duration) | Exit criteria |
|---|---|---|---|
| Deploy | <shadow, tap compare, dependency check> | | |
| Release | <canary, cohort, traffic shift> | | |
| Post-release | <synthetic checks, flag cleanup, fault injection> | | |
## Abort criteria
| Signal (test population) | Baseline | Threshold | Min sample | Action | Auto or owner |
|---|---|---|---|---|---|
Time to stop (rehearsed on <date>): <minutes>
Stop word: <phrase>; anyone in <channel> can use it
## Side effects
| Operation | Idempotent? | How the test is kept from doing it |
|---|---|---|
## Oracle
Fields on every event: <build, flag states, cohort>
Query that separates the test population: <query or link>
## Synthetic checks after release
<journeys, interval, locations, test accounts>
## Exclusions
- <what is not tested in production> — <where that evidence comes from>
## Informed
Support · On-call · <others>
## Record
<start, phase changes, aborts with reason, result> WORKED EXAMPLE
Avocet Pay is a fictional payment gateway: 2,300 merchants, about 1.4 million card authorisations a day, 180 people. The routing team has rewritten the engine that picks which acquirer handles each card payment. The QA lead wrote this plan with the routing engineer and an SRE.
Why production. Staging has 40 test merchants and acquirer sandboxes that approve everything. It cannot show routing decisions against real merchant configs (some date from 2017) or real acquirer decline patterns.
Deploy phase. Shadow 10% of live authorisation requests to the new engine in decide-only mode: it returns a routing choice and never calls an acquirer. Tap compare against the old engine’s choice. Noise floor measured by shadowing the old engine against itself for a day: 0.02% mismatches from a tie-break ordering, normalised away. Exit: seven days, unexplained mismatches under 0.05%, every category ticketed. Blast radius: no user effect; shared routing-config database load checked at 10% sampling, 6% CPU increase.
Release phase. New engine routes for 25 named merchants who agreed to the pilot, capped at $500,000 a day across them. Abort if authorisation approval rate for the pilot cohort falls more than 1.5 percentage points below the baseline cohort over at least 2,000 authorisations, or if p99 routing latency exceeds 40 ms. Action: flag off, automatic. Rehearsed time to stop: 90 seconds. Then 10%, 50%, 100% of merchants, a week each.
Oracle. Every authorisation event carries engine version, flag state and cohort; the comparison query is saved and linked.
Exclusions. Refund routing is not in this change and not tested. Acquirer failover is tested in the certification environment.
Result. The shadow phase found mismatches on 0.3% of shadowed requests, all from merchants with a legacy currency setting the new engine ignored. Fixed before release; the canary ran clean.
Now you
You are the quality engineering lead at Shrike, a fictional company selling an in-app chat SDK used by 600 customer apps with about 9 million monthly active end users. The messaging team has replaced the delivery service that fans messages out to devices: new queue, new push provider integration. Staging delivers everything instantly because it has 200 test devices and no real push provider throttling. Four customer apps send 60% of all traffic. Complications: messages delivered to phones cannot be recalled; two of the large customers are healthcare apps whose contracts forbid test messages to their users; and the current per-event telemetry records message id but not which delivery service handled it. The engineering director wants the new service at 100% in three weeks. Write the production test plan: phases, blast radius, abort criteria, how you handle the irreversibility, what you do about the healthcare customers, and what telemetry must change before the first phase starts.
Self-check
You are the QA lead at Avocet Pay. Last month a change to settlement batching passed every staging test and failed in production, because production batches contained merchant records with a legacy fee structure staging does not have. Settlements were late for 140 merchants for a day. The VP of engineering offers two quarters of a platform engineer and a budget for a full-fidelity staging environment with nightly anonymised copies of production data. The SRE lead argues the same money should go into a shadow-traffic platform, version-tagged telemetry and canary analysis. You have to recommend one.
- POST Testing in Production, the safe way Cindy Sridharan, 2018
The essay behind this chapter's three phases, deploy, release and post-release, with the techniques for each. Long, and worth reading in full before you write your first plan.
- POST I test in prod Charity Majors, 2019
The case for admitting that production is where the real test happens, with the Honeycomb upgrade story from the opening. Read it for the argument about diminishing returns from pre-production testing.
- POST Testing in Production: Why You Should Never Stop Doing It Charity Majors
The later, more practical version: what to invest in, canaries, fast rollback, flags and observability, so that production testing is safe. Useful to hand to an engineering manager who is not convinced.
- POST Scientist: Measure Twice, Cut Once Jesse Toth, GitHub, 2016
How GitHub ran old and new code side by side on real inputs and recorded mismatches before switching over. The clearest description of tap compare and its pitfalls.
- HANDBOOK Canarying Releases Google SRE, 2018
How to choose canary metrics, size the canary population and compare against a baseline. Read the sections on metric selection with a broken feature in mind.
- POST Dark Launching Martin Fowler, 2020
A short definition of running new back-end behaviour for real users without showing them the result. Useful vocabulary for the deploy phase.
- DOC Principles of Chaos Engineering
The rules for fault injection in production: hypothesis about steady state, real-world events, minimal blast radius. Read it before your first game day.
All companies and people in these examples are fictional. Any resemblance to a real business or person is unintended.