Day 58 Hard Experimentation Release Safety Statistics 2026-11-19

Experiment Design at Coarse GranularityCUPED and Switchback When You Can Only Randomize Tenants

Scenario + Requirements

You own change verification for a multi-tenant compute platform: about 3,000 tenant resource pools, jobs inside a pool share one compute quota, and the platform serves roughly 100 million requests a day. A performance-only optimization sits behind a flag, and you need to answer one question: how much did it change job duration?

Randomizing by request gives the most samples, but it does not work here. Inside one pool, quota that treatment saves is consumed by control, and customers will not accept a pipeline that is fast for half its queries and slow for the other half. The unit has to move up to the resource pool, and that costs three things:

Requirements: detect a 1% regression within two weeks; A/A false positive rate at the nominal 5%; a consistent customer experience within any time window; automatic stop when a guardrail trips.

Core insight: granularity is not a preference. Its lower bound is set by interference: the randomization unit cannot be smaller than the boundary of the shared resource. On that bound, two tools buy statistical power back. CUPED removes differences between units that were there before the experiment, and switchback lets every unit be its own control.

High-Level Architecture

graph TD
    C["Change + flag metadata
stateful? changes results? shared resource?"] --> P{"Design selector"} P --> F["Fixed assignment
stratified randomization"] P --> S["Switchback
randomized schedule"] F --> E["Flag evaluation
pinned at request start"] S --> E E --> X[("Exposure log")] X --> G["Aggregate by randomization unit"] H[("Pre-experiment baseline")] --> G G --> A["Analysis
CUPED · paired differences · randomization test"] AA["A/A replay gate"] -.-> A A --> V["Verdict + guardrail auto-stop"]

The design selector reads flag metadata and decides which experiment designs this change is allowed to use. Flag evaluation reads the value at request start and pins it, so a request belongs to one arm for its whole life. The exposure log records which arm each request was in, and every analysis depends on it. Aggregation always happens at the randomization unit and is joined with the pre-experiment baseline. The A/A replay gate uses historical data to verify the false positive rate of a given design-plus-analysis pair before any real experiment may use it.

Key Point 1: Choosing the Unit — Interference Sets the Floor

One-line trade-off: a finer unit gives more samples, but if the two arms share a resource the estimate is biased; a coarser unit is cleaner and has less power.

Principle

An A/B test assumes that a unit's outcome depends only on its own assignment (SUTVA). A shared resource pool breaks that assumption, and the bias can go either way. If treatment frees quota, control speeds up too and the effect is underestimated. If treatment uses more resources, control is squeezed, the gap is overestimated, and the "gain" vanishes at full rollout. Two rules follow: the randomization unit is never smaller than the resource-sharing boundary, and the analysis unit equals the randomization unit. Assigning by pool and then treating each request as an independent sample overstates the sample size by orders of magnitude.

Trade-offs

Randomization unitWhat you getWhat you give up
RequestMost samples, an answer in hoursInterference within the pool; inconsistent experience for one customer
Project / userConsistent customer experienceProjects in the same pool still compete for one quota, so interference remains
Resource poolInterference is closed inside the unitOnly a few thousand units; heavy tail and heterogeneity dominate the variance
Cluster / regionEven cross-pool shared layers are closedOnly tens of units; a fixed split detects almost nothing

Pseudo-code

# How much power a coarse unit really costs (pseudo-code)
def n_eff(n_requests, m_per_unit, icc):
    return n_requests / (1 + (m_per_unit - 1) * icc)    # design effect

def mde(sigma, n_per_group, z_alpha=1.96, z_power=0.84):
    return (z_alpha + z_power) * sigma * (2 / n_per_group) ** 0.5

n_eff(1e8, m_per_unit=33_000, icc=0.2)   # ~15,000: 100M requests are nowhere near 100M independent samples
mde(sigma=0.5, n_per_group=1500)          # ~0.051: a fixed split by pool only detects a 5% change
Real-world case: Spang et al. (IMC 2021) compared two congestion control algorithms in the lab. When only a few flows used the new algorithm, it appeared to deliver 150% higher throughput; when most flows used it, 75% lower; yet the two have identical throughput when all traffic uses either one. In a bitrate-capping experiment run with Netflix, naive A/B tests got the direction of improvement wrong for minimum RTT and average throughput. DoorDash's pricing experiments have the same problem: both groups of consumers share one fleet of couriers.

Key Point 2: CUPED — Remove the Differences That Were Already There

One-line trade-off: it changes neither assignment nor customer experience, so it is nearly free; but it only reduces variance, does not fix bias, and how much it helps depends entirely on how well the metric correlates with its own past.

Principle

Large pools were already slow and small pools were already fast, and that difference has nothing to do with the experiment. CUPED removes it using each unit's value of the same metric before the experiment, X:

Y' = Y − θ·(X − mean(X))      θ = Cov(X, Y) / Var(X)      Var(Y') = (1 − ρ²)·Var(Y)

Because assignment is random, X has the same expectation in both arms, so subtracting it introduces no bias. ρ, the correlation between X and Y, decides how much you save:

ρRemaining varianceEquivalent sample multiplier
0.575%1.3×
0.751%2.0×
0.919%5.3×
0.9510%10×

Four rules. The covariate must come entirely from before the experiment, or it will subtract the treatment effect along with the noise. Take logs or winsorize heavy-tailed metrics first. Use the delta method for the variance of ratio metrics. Put new units with no history in a stratum of their own. At assignment time, also stratify by size so large pools are balanced across arms.

Pseudo-code

import numpy as np

def cuped(y, x, treated):
    """y: metric during the experiment; x: same metric, same unit, before it; treated: bool array"""
    theta = np.cov(x, y)[0, 1] / np.var(x, ddof=1)       # estimate θ on both arms pooled
    y_adj = y - theta * (x - x.mean())
    t, c = y_adj[treated], y_adj[~treated]
    delta = t.mean() - c.mean()
    se = np.sqrt(t.var(ddof=1) / len(t) + c.var(ddof=1) / len(c))
    return delta, se
# heavy-tailed metrics: first y, x = np.log(y), np.log(x)
Real-world case: CUPED comes from Bing (Deng, Xu, Kohavi, Walker, WSDM 2013): variance fell by about 50%, equivalent to using half the users or half the time. Three experiments with one week of experiment data and one week of pre-experiment data showed reductions of 45%, 52% and 49%, and the best single covariate was the same metric measured before the experiment. It is not guaranteed to help, though. Microsoft's ExP team reported in 2022 that on two surfaces of the same product, one had more than 68% of metrics with an effective traffic multiplier of at most 1.05x, while the other had more than 55% of metrics above 1.2x. Measure ρ on historical data first.

Key Point 3: Switchback — Let Every Unit Be Its Own Control

One-line trade-off: it removes heterogeneity and within-pool interference at the same time; the price is carryover across time, and it only works for changes that can be flipped back and forth.

Principle

What gets randomized changes from "which units" to "which time windows". The same pool runs with the flag on for some windows and off for others, and differences between pools cancel in the subtraction. Five design decisions:

  1. The unit is the resource pool, and the whole pool has one value within a window.
  2. Window length must cover carryover and the business cycle. A batch platform uses one day and runs for two to four weeks, so every daily job runs under both arms and every weekday appears in both.
  3. The sequence is random, not a fixed on/off alternation: pair adjacent days and randomize within the pair, so the schedule cannot line up with periodic jobs.
  4. Each pool is randomized independently: on any day some pools are on and some are off, so a global event is not confounded with treatment.
  5. Discard a burn-in after each switch: caches, connection pools and long jobs that cross the boundary all carry state from the previous window.
PoolD1D2D3D4D5D6
pool-aonoffoffononoff
pool-boffonoffononoff
pool-conoffonoffoffon

In analysis each pool yields one number: the mean of its on windows minus the mean of its off windows. Then run a paired test or a randomization test across pools.

Pseudo-code

import hashlib, numpy as np

def arm(exp_id, pool_id, day):                 # pair adjacent days, randomize within the pair
    pair, pos = divmod(day, 2)
    h = hashlib.sha256(f"{exp_id}:{pool_id}:{pair}".encode()).digest()[0] & 1
    return "on" if h == pos else "off"         # each pair has exactly one on day and one off day

def analyze(rows, burn_in_h=2):                # rows: (pool, day, hour, arm, value)
    by_pool = {}
    for pool, day, hour, a, v in rows:
        if hour < burn_in_h: continue           # discard the burn-in after a switch
        by_pool.setdefault(pool, {"on": [], "off": []})[a].append(v)
    d = np.array([np.mean(g["on"]) - np.mean(g["off"]) for g in by_pool.values()])
    return d.mean(), d.std(ddof=1) / np.sqrt(len(d))    # analysis unit = resource pool
Real-world case: DoorDash in 2018 randomized on "region × time window" units, flipping a coin independently for every window. Windows were typically 30 minutes and regions roughly city-level, and the window length was chosen using long-running A/A tests. Its 2019 simulations supply the cautionary number: a t-test that treats every delivery as an independent sample had a false positive rate of 0.62; a multilevel model brought it to 0.03 with power of 0.93. On the theory side, Bojinov, Simchi-Levi and Zhao (Management Science, 2023) derived the optimal design as a function of the order of the carryover effect and gave exact randomization-based p-values.

Key Point 4: Make the Design a Property of the Flag, Then Add an A/A Gate

One-line trade-off: one site-wide rule is easy to explain but makes most changes pay for the constraints of a few; choosing the design by change type gives more power but depends on trustworthy metadata.

Principle

Change typeAllowed designWhy
Stateful (storage format, metadata writes)Fixed assignment, forward onlyCannot be flipped back and forth
Changes results or semanticsFixed assignment, shadow comparison firstThe same request returning different results on different days is an incident
Same results, performance onlySwitchback, unit is the resource poolEach unit is its own control, highest power
Affects shared-resource efficiencyUnit no smaller than the resource poolAnything finer contaminates the other arm

Metadata will be filled in wrong, so you also need a gate that does not depend on the change: A/A replay. Take historical data, assign it randomly under the same design a thousand times with no real change, and the share of runs with p < 0.05 should sit near 5%. If it is clearly higher, the analysis unit or the variance estimate is wrong.

Pseudo-code

def choose_design(flag):
    if flag.stateful:        return Fixed(unit="pool", reversible=False)
    if flag.changes_results: return Fixed(unit="project", shadow_first=True)
    if flag.expected_effect_small:
        return Switchback(unit="pool", window="1d")
    return Fixed(unit="pool", stratify="size", cuped=True)

def aa_gate(history, design, analyze, runs=1000, alpha=0.05):
    fp = sum(analyze(design.assign(history, seed=s)).p < alpha for s in range(runs))
    return abs(fp / runs - alpha) < 0.015       # refuse the design if it drifts from nominal
Real-world case: Spang et al. recommend two steps for network algorithms. Treat the gradual deployment you already run as an event study and check whether the effect changes with the allocation fraction, which reveals interference. Then use small, targeted switchbacks to measure the effect accurately. In DoorDash's two posts, both the window length and the analysis method were chosen with A/A tests, some run live and some simulated on historical data.

Scaling and Optimization

Common Pitfalls + Interview Questions

Crossovers

Ten takeaways

  1. The randomization unit cannot be smaller than the resource-sharing boundary, or treatment and control affect each other and the estimate is biased.
  2. Bias from interference has no fixed direction: a change that saves resources is underestimated, one that uses more is overestimated.
  3. The analysis unit must equal the randomization unit; in DoorDash's simulations a per-delivery t-test had a false positive rate of 0.62.
  4. A fixed split by resource pool costs you sample size, a heavy tail and heterogeneity, which together push the minimum detectable effect to several percent.
  5. CUPED uses the same metric from before the experiment as a covariate; variance is multiplied by one minus ρ squared, leaving 19% at ρ = 0.9.
  6. CUPED's covariate must come entirely from before the experiment; a variable the treatment affects subtracts the effect along with the noise.
  7. CUPED cut Bing's variance by about half, but Microsoft has also reported a product surface where most metrics gained almost nothing, so measure the correlation first.
  8. A switchback turns the flag on and off for the same resource pool in different time windows, so differences between units cancel in the subtraction.
  9. A switchback needs a random sequence, independent pools and a discarded burn-in, and fits only stateless changes that do not alter results.
  10. Experiment design should be a property of the flag, decided by change type; any new design passes an A/A replay gate before use.

Further Resources

Reflections

3,000 resource pools, a pool-level coefficient of variation of 0.5, and you want to detect a 1% regression within two weeks. How far do a fixed split, CUPED and a switchback each get you?

Fixed split: 1,500 per arm gives a standard error of 0.5 × √(2/1500) ≈ 1.8%, and the minimum detectable effect is about 2.8 standard errors, or 5%. With CUPED at ρ = 0.9, multiply by √0.19 to get about 2.2%; reaching 1% needs ρ ≈ 0.98. Switchback: assume a day-to-day coefficient of variation of 0.1 within one pool and two weeks with 7 days on and 7 off. The standard deviation of one pool's difference is about 0.1 × √(2/7) ≈ 5.3%, the standard error across 3,000 pools is about 0.1%, and the detectable effect is about 0.3%. Even with only 500 pools it reaches roughly 0.7%. The gap comes from one fact: day-to-day variation within a pool is far smaller than the differences between pools. All of these inputs are assumptions; the real values have to be measured from historical data and A/A replay.

The change takes a week to show its effect (it affects background compaction, say, or a cache that fills gradually). Can you still use a switchback?

Not with daily windows. Carryover is longer than the window, so what you measure in an on window is still the off state, the effect is diluted, and no amount of burn-in is enough. There are two ways out. Stretch the window to several times the carryover (two-week windows, say, which leaves only a handful of windows in several months and no power). Or accept that this is a slow-variable change and go back to a fixed split with CUPED, trading a longer experiment for power. How long carryover lasts can itself be measured: turn the change fully on and watch how long the metric takes to settle. Bojinov et al. also give a data-driven procedure for identifying the order of carryover.

There are only 30 large customer pools, and they account for most of the traffic. How do you run an experiment?

A fixed split is close to hopeless: 15 against 15, and whichever arm draws the largest pool decides the outcome. CUPED cannot rescue a unit count that small. Switchback is the main route: each pool is its own control, and 30 pools × 28 days gives 840 pool-days. Do not lean on a normal approximation for inference; use a randomization test. Regenerate a few thousand schedules under the same rule and see where the real difference ranks, which gives an exact p-value. Run for longer, and accept that only larger effects are detectable. This is also why sensitive large customers are better served by shadow execution: they carry no risk and you still get paired data.

The platform runs 100 experiments a day, each watching 20 metrics. What does a 5% A/A false positive rate mean, and how does it relate to Day 51 on alerting under a low base rate?

That is 2,000 tests a day, so about 100 come out "significant" with no real regression at all. If there are only one or two real regressions a day, the chance that a given alert is real is 1% to 2%, which is exactly the base-rate problem from Day 51: a low per-test false positive rate does not make an alert trustworthy. The remedies are the same. Lower the per-test false positive rate (stricter guardrail thresholds, multiple-comparison correction). Shrink the decision domain (only look at metrics the metadata says could be affected). Chain an independent layer of evidence (a regression counts only if it reproduces in a second window).

Compare this issue with Day 44 on chaos engineering. Both split production traffic into control and experiment groups. What is different?

A chaos experiment injects a fault with a large effect over a short time, and the goal is to falsify the hypothesis that steady state holds. A comparison lasting tens of minutes is enough, sample size is not the bottleneck, and blast radius is. A performance change is the opposite: the effect is around one percent, the risk is low, and the bottleneck is power. So the first spends its effort on automatic abort and radius control, the second on variance reduction. What they share is the question "were the two groups the same to begin with?" Chaos experiments answer it with a control group from the same time window and the same routing rule; this issue answers it with stratification, CUPED and self-control.