Experimentation Platforms and Infrastructure Questions
Infrastructure for A/B testing and experimentation: assignment/bucketing, metric pipelines for experiments, guardrail and variance-reduction plumbing, and experiment result storage. Covers building the platform that powers trustworthy online experiments at scale. Distinct from the statistics of experiment analysis.
Propose a cost-effective retention and aggregation policy for experiment telemetry that balances the need to re-analyze history against storage cost: tiered hot/warm/cold storage, pre-aggregation intervals, sampled raw retention for long-tail analyses, and TTLs. How do these choices limit your ability to re-run a historical experiment later?
Sample Answer
Direct answer
Use tiered hot/warm/cold storage for experiment telemetry: keep recent, full-fidelity raw events hot for active experiments and any still-open re-analysis window, roll older data to a cheaper warm tier with pre-aggregated summaries plus a sampled subset of raw events, and move the oldest data to cold, sampled-only storage with a defined TTL, accepting that a very old experiment can only be re-analyzed at reduced fidelity, not re-derived from full raw data.
Structured elaboration
- Hot tier: full raw events for currently-running or recently-concluded experiments, prioritizing fast query access for active analysis and any near-term re-analysis need.
- Warm tier: pre-aggregated metric summaries (daily rollups per variant) for all historical experiments, plus a SAMPLED subset of raw events (say, 5 or 10 percent) retained at full fidelity, which is enough to investigate a specific anomaly or re-derive an approximate answer without keeping every raw event indefinitely.
- Cold tier: only the pre-aggregated summaries and sampled raw data survive past a defined retention window; full raw event data for old experiments is deleted or archived to the cheapest possible storage with a TTL, since keeping every raw event for every experiment forever is usually not justified by how often anyone actually needs it.
- Impact on re-running historical experiments: a re-analysis within the hot-tier window can use the full, exact data; a re-analysis of an old experiment can only work from the pre-aggregated rollups and sampled raw data, which is fine for confirming a headline number but insufficient for a genuinely new, fine-grained analysis question (like a previously-unexamined segment cut) that the original aggregation didn't anticipate.
Worked example
Eighteen months after an experiment concluded, a new team wants to check whether the effect held for a specific user segment nobody originally analyzed. If that experiment's data has aged into the cold tier (aggregates plus a 5% raw sample only), the team can get an approximate, noisier answer from the sample, but cannot get the same precision a fresh analysis on the full original dataset would have provided; this trade-off should be an explicit, documented policy decision, not a surprise the team discovers only when they try and fail to get a precise answer.
Trade-offs and pitfalls
Setting the hot-tier window too short saves storage cost but frustrates legitimate near-term re-analysis needs that come up more often than teams initially expect (a follow-up question a week after the "final" report); setting it too long defeats the cost-saving purpose of tiering at all. The sampled-raw-data retention in the warm and cold tiers is the key lever that keeps SOME re-analysis capability alive at much lower cost than keeping everything at full fidelity forever, and it's worth communicating its existence (and its limits) clearly to teams rather than letting them assume old data is either fully available or fully gone.
Design experiment infrastructure for validating a new ML model in production: shadow testing, a canary model route, holdout groups, model versioning, and feature-store dependencies. How does rollout gating differ when the metrics you're gating on are model-specific (inference latency, fairness checks) rather than generic product metrics, and what does rollback look like for a model regression?
Sample Answer
Direct answer
Validating a new ML model online needs infrastructure beyond a standard A/B test: shadow testing (running the new model's predictions alongside production without acting on them, to catch problems before any user is affected), canary model routes (a small, controlled slice of real traffic on the new model), holdout groups (a slice permanently withheld from any model update, to measure drift in the underlying population over time), model versioning tied to every prediction logged, and rollback gated on model-specific metrics like inference latency and fairness checks, not just the product's usual business metrics.
Structured elaboration
- Shadow testing: the new model runs on live traffic in parallel with the production model, its predictions logged but never shown to users; this catches gross failures (crashes, wildly wrong predictions, latency blowups) with zero user-facing risk, before the model is trusted enough to touch a canary.
- Canary model routes: once shadow testing passes, route a small percentage of real traffic to the new model's actual predictions, gated the same way a code canary is, with automated rollback if model-specific guardrails breach.
- Holdout groups: a slice of traffic permanently kept on an OLDER, frozen model version (not necessarily the immediately-prior one) gives a stable baseline to detect population-level drift over time, distinct from the canary's job of validating a specific new version.
- Model versioning: every prediction logged with the exact model version that produced it, which is what makes a later question like "was this specific bad recommendation from the new model or the old one" answerable at all.
- Feature-store dependencies: the platform needs to track which feature-store version and feature definitions a given model version was trained and served against, since a feature-definition change (even without touching the model itself) can silently degrade predictions if serving-time features drift from what the model was trained on.
- Model-specific rollout gating: inference latency and fairness checks (disparate performance across user segments) are guardrails a standard product experiment wouldn't naturally include, and both need to gate rollout the same way a business-metric guardrail does.
- Rollback for model regressions: reverting to a prior model version needs to be as fast and as automatable as reverting a code deploy, since a model regression (systematically worse recommendations for a segment) can be just as costly as a code bug.
- Champion-challenger automation: once a canary is trusted, the platform can automate the promote-or-kill decision itself (a "champion-challenger" pattern), continuously testing a challenger model against the current champion and auto-promoting a winner once it clears both the statistical bar and every guardrail, which matters specifically under non-stationarity, where a model that was the best choice last month may not be today.
- Handling noisy online metrics for personalization: personalization rollouts often show noisy primary metrics, so the platform should let a team define a minimum-detectable-effect target and pay attention to whether metrics move consistently across segments rather than trusting one noisy aggregate number; two model versions that look similar in aggregate can still diverge sharply for a specific segment, which is exactly what the fairness and segment-level guardrails above are built to catch.
- Feedback loops and population shift: a model that influences what users see also influences what data gets collected next (a recommendation model shapes future training data), so continuous evaluation needs to watch for the model's own predictions drifting the underlying population it's being measured against, not just for the model's accuracy degrading in isolation.
- Comparing two model versions specifically: the simplest case of this infrastructure, A/B testing exactly two model versions with deterministic bucketing and an offline analysis pipeline reading the same exposure and outcome events described elsewhere, is the same infrastructure at smaller scope, not a separate system.
Worked example
A new recommendation model passes shadow testing cleanly (predictions look reasonable, latency is fine) and is canaried to 5% of traffic. A fairness guardrail then flags materially worse recommendation quality for a specific user segment that wasn't well represented in the new model's training data, a regression the shadow test's aggregate-latency-and-crash checks would never have caught, since it required actually observing engagement outcomes for that segment specifically once the canary was live.
Trade-offs and pitfalls
Shadow testing catches failures cheaply but can't catch anything that depends on the model actually influencing user behavior (since shadow predictions are never shown to anyone), which is exactly why a canary stage is still needed even after a clean shadow run. The other common mistake is gating rollout only on the usual business metrics and skipping model-specific checks like fairness across segments, which can leave a real regression invisible in the aggregate metric while it's actively harming a specific, smaller population.
You must join exposure logs from one service with conversion events from a different service to compute experiment metrics, and the two systems use different timezone conventions and session-windowing heuristics. Design a reconciliation process: canonical timestamps, session windowing, deduplication keys, handling of late-arriving events, idempotency, and the tests you would write to prove the joined metric is correct.
Sample Answer
Direct answer
Design the reconciliation around canonical UTC timestamps computed as close to the source as possible, a shared, explicit session-windowing definition both services agree to use (rather than each inferring sessions independently), deduplication keys based on a stable event id rather than a recomputed hash, idempotent processing so a retry doesn't double-count, and automated tests that assert the joined output on a known input produces a known, hand-verified result.
Structured elaboration
- Canonical timestamps: convert every timestamp to UTC at the earliest possible point (ideally at the source service, not downstream), and store the original timezone/offset alongside it for debugging, since a downstream conversion error is much harder to spot after the original context is lost.
- Session windowing: if Service A and Service B use different session-timeout definitions (say, 30 minutes of inactivity versus a fixed calendar day), events that should logically belong to the same session can get split differently by each service; the reconciliation process needs a single, explicitly agreed session definition applied consistently across both, computed at reconciliation time rather than trusting each service's own internal session boundary.
- Deduplication keys: use a stable, source-assigned event id (not a hash of mutable fields, which can change if any field is corrected or reprocessed) so a legitimate retry is recognized as the same event rather than treated as new.
- Late-arriving events: define an explicit lateness tolerance (how long after a session's nominal end an event can still arrive and be included) consistent with the storage-tiering and watermarking approach used elsewhere in the pipeline.
- Idempotency: the join and aggregation logic should produce the same result whether run once or replayed multiple times over the same input, which usually means writing to an idempotent sink (an upsert keyed by the same deduplication key) rather than a naive append.
- Tests for correctness: a golden-file style test with hand-constructed events from both services, including a case that straddles a timezone boundary and a case with a legitimate retry, verifying the joined output matches a manually-computed expected result.
Worked example
Service A logs an exposure at 23:50 local time in a timezone that's UTC+9, while Service B logs the matching conversion event using a server timestamp already in UTC. Without converting Service A's timestamp to UTC before comparison, a naive join could conclude the conversion happened BEFORE the exposure (since 23:50 local time is actually 14:50 UTC the same day, a nine-hour difference that a naive string or local-time comparison would miss entirely), silently excluding a legitimate conversion from the metric.
Trade-offs and pitfalls
Trusting each service's own internal session or timestamp handling instead of establishing one shared, explicit definition at reconciliation time is the root cause of most cross-service join bugs like this; it's tempting because it requires no coordination between the two teams, but it's exactly the coordination that prevents silent, hard-to-detect metric corruption. The cost of building the shared reconciliation layer (agreeing on and enforcing one canonical timestamp and session definition) is real coordination overhead between two teams, but it's cheap relative to the cost of a metric quietly being wrong for months before anyone traces it back to a timezone mismatch.
Design a scalable automated validity-check engine for an experimentation platform: it should run pre-launch and continuous post-launch checks covering SRM, instrumentation drift, delayed events, outliers, and contamination or leakage between variants. Describe the architecture, how rules execute, where machine-learning-based anomaly detection helps versus rule-based checks, and the remediation workflow when a check fails.
Sample Answer
Direct answer
A validity-check engine needs a rule-execution layer that runs a defined library of checks (SRM, instrumentation drift, delayed events, outliers, contamination) both once before launch and continuously during the run, an architecture that separates fast rule-based checks from slower machine-learning-based anomaly detection, and a remediation workflow that turns a failing check into a specific, actionable next step rather than just a red dot on a dashboard.
Structured elaboration
flowchart TD
Launch[Experiment Launch Request] --> PreCheck[Pre-launch rule engine]
PreCheck -->|pass| Live[Live Traffic]
PreCheck -->|fail| Block[Block launch, report reason]
Live --> Continuous[Continuous check scheduler]
Continuous --> RuleChecks[Rule-based: SRM, delayed events, outliers]
Continuous --> MLChecks[ML-based: drift, contamination anomaly scoring]
RuleChecks --> Remediation[Remediation workflow]
MLChecks --> Remediation
Remediation --> Pause[Auto-pause]
Remediation --> Page[Page owner]
- Rule-based checks (SRM, an event-volume floor, a delayed-events percentage) are cheap, deterministic, and explainable, which makes them a good fit for anything that needs to BLOCK a launch outright.
- ML-based anomaly detection earns its keep specifically where a fixed rule would be too rigid: detecting contamination between two experiments that share partial traffic, or flagging a metric drift pattern that doesn't fit a simple threshold (a gradual, compounding drift rather than a sudden step change). The trade-off is explainability: a rule-based check can tell an engineer exactly which threshold was crossed; an ML-based flag often needs a secondary "why did this fire" explanation layer or it becomes a black box nobody trusts.
- Remediation workflows: every failing check should map to a specific downstream action (block launch, pause new exposure, flag reporting as unreliable, page an owner), not just an entry in a generic alerts feed, since an alert with no clear next action trains people to ignore the whole system.
- Naming the drift taxonomy explicitly: "drift" isn't one thing; the engine should distinguish a mean shift (the metric's average level moved), a variance increase (the metric got noisier without necessarily moving on average), and a distributional change (the shape changed even if the mean looks stable), because each implies a different root cause and a different fix, and reporting all three under one generic "drift detected" label makes triage slower, not faster.
- An incident-response playbook for false positives specifically: because this engine runs continuously across every active experiment, it will generate false alarms; a documented playbook (check the last deploy, check SDK-version breakdown, check whether the same alert fired on an unrelated experiment at the same time, which would point at a platform-wide issue rather than an experiment-specific one) keeps a false-positive investigation fast and consistent rather than reinvented each time.
Worked example
A contamination check using a rule-based threshold (say, more than 5% user overlap between two experiments) would miss a subtler case: two experiments with only 2% direct user overlap but where that 2% happens to be disproportionately high-value users who account for a large share of the metric's variance. An ML-based anomaly model trained to weight overlap by its expected influence on the outcome metric, rather than raw user-count overlap, catches this case that a flat threshold rule would pass cleanly.
Trade-offs and pitfalls
Building the ML layer before the rule-based layer is a common overreach: most of the value (catching SRM, instrumentation drift, obvious contamination) comes from cheap, explainable rules, and ML-based anomaly detection should be reserved for the residual cases rules genuinely can't express, not used as the default approach everywhere. The other pitfall is under-investing in the remediation workflow itself: a technically excellent detection engine that only produces a dashboard nobody acts on has the same practical effect as no detection engine at all.
Given exposures, events, and users tables, describe how you would compute normalized lift and a bootstrap confidence interval for the metric purchase_value per variant over a 14-day window. Outline the SQL for the aggregation step and sketch the Python for the bootstrap, including how you handle user-level aggregation and stratified resampling.
Sample Answer
Direct answer
Aggregate purchase_value per user per variant in SQL first (so each user contributes exactly one row), then bootstrap by resampling users WITH replacement independently within each arm, recomputing the relative lift on each resample, and taking the 2.5th and 97.5th percentiles of the resulting distribution as the 95% confidence interval; user-level resampling, not event-level, is what correctly respects the actual unit of randomization.
Structured elaboration
SQL aggregation sketch:
SELECT e.variant, e.user_id,
COALESCE(SUM(CASE WHEN ev.event_type='purchase'
AND ev.occurred_at >= e.assigned_at
AND ev.occurred_at <= e.assigned_at + INTERVAL '14 days'
THEN ev.value ELSE 0 END), 0) AS purchase_value
FROM exposures e LEFT JOIN events ev ON ev.user_id = e.user_id
GROUP BY e.variant, e.user_id;
Both bounds of the attribution window matter: the upper bound (assigned_at + 14 days) caps how long after assignment a purchase still counts, but the lower bound (ev.occurred_at >= e.assigned_at) is just as necessary, without it the join would sum a user's entire purchase history, including purchases made long before the experiment even existed, into purchase_value, since the CASE condition only ever checked the upper bound. That silently inflates purchase_value for any user with pre-experiment purchase history and corrupts the metric everything downstream depends on.
Python bootstrap sketch (executed and verified):
def bootstrap_lift_ci(control_values, treatment_values, n_boot=2000, seed=42):
rng = random.Random(seed)
n_c, n_t = len(control_values), len(treatment_values)
lifts = []
for _ in range(n_boot):
c_sample = [control_values[rng.randrange(n_c)] for _ in range(n_c)]
t_sample = [treatment_values[rng.randrange(n_t)] for _ in range(n_t)]
c_mean, t_mean = sum(c_sample)/n_c, sum(t_sample)/n_t
if c_mean != 0:
lifts.append((t_mean - c_mean) / c_mean)
lifts.sort()
lo, hi = lifts[int(0.025*len(lifts))], lifts[int(0.975*len(lifts))]
point = (sum(treatment_values)/n_t - sum(control_values)/n_c) / (sum(control_values)/n_c)
return point, lo, hi
User-level aggregation matters because the randomization unit was the USER, not the event; resampling individual purchase events would treat a high-frequency purchaser's many events as many independent observations, when they're really one randomized unit. Stratified resampling (resampling within each variant independently, as done here) preserves each arm's own sample size in every bootstrap draw, keeping the comparison apples-to-apples.
Worked example (executed)
On a synthetic dataset with a known true +20% lift (control drawn from a distribution with mean 20, treatment from one with mean 24, 3,000 users per arm), the bootstrap produced a point estimate of approximately 0.19 with a 95% CI of roughly [0.17, 0.22], correctly containing the true 0.20 lift. On a null case (both arms drawn from the identical distribution), the CI straddled zero (approximately [-0.02, 0.02]), correctly showing no significant difference.
Trade-offs and pitfalls
Bootstrapping at the event level instead of the user level is the most common version of this mistake, and it understates the true variance because it implicitly treats a user's multiple purchases as independent randomized units when they aren't. A second common mistake, seen in an earlier draft of the SQL above, is an attribution window that only enforces its upper bound and forgets the lower one, silently pulling in a user's entire purchase history rather than just the post-assignment window; always write and test both bounds explicitly. The other pitfall is a small sample size making the percentile bootstrap itself noisy (with very few users per arm, 2,000 resamples of a tiny population doesn't manufacture information that isn't there); in that regime a parametric or bias-corrected bootstrap method is usually more appropriate than the plain percentile method used here.
Unlock Full Question Bank
Get access to all Experimentation Platforms and Infrastructure interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.