In this article
Before you start
This page belongs to the statistics interview guide. The A/B testing interview questions page covers the wider family of experiment prompts.
Why interviewers ask this
A badly designed ranking experiment ships a worse ranker or kills a better one, and the dashboard looks confident either way. Interviewers use the question to see whether a candidate can turn a vague goal, "is the new ranker better?", into a plan that survives scrutiny.
A weak answer says "split users 50/50 and compare click-through rate." A strong answer names the unit of randomization, the primary metric and the guardrails, the sample size and the stopping rule. A Staff-level answer adds what to check before reading any result and what to do when many candidate rankers are waiting for a test slot. The rubric below shows the difference line by line.
A/B test for a ranking algorithm from first principles
- Sample ratio mismatch (SRM)
- Sample ratio mismatch is a gap between the group sizes an experiment was designed to produce and the sizes it actually produced, large enough that chance does not explain it. It signals a bug in assignment or logging, so the results cannot be trusted.
- Interleaving
- Interleaving is a test design that shows each user one blended list built from two rankers and credits every click to the ranker that contributed the clicked item. It measures preference inside each user instead of comparing two groups.
In plain words
Imagine a café that wants to know whether a new menu order sells more coffee. It shows the old menu to a random half of customers and the new one to the other half. Then it compares sales. That is an A/B test: a randomized experiment that gives two groups different versions and compares one outcome.
The analogy breaks in one place. Customers pick once. Search users come back every day and learn, so who sees what, and for how long, matters far more.
In one precise sentence, a ranking A/B test estimates the causal effect of the new ranker on a chosen metric by comparing randomly assigned groups. Randomization is what lets you read the difference as cause, not just correlation.
Step 1: Randomize by user, then check the split before reading results
Randomize by user so each person sees one ranker. Assign each account once, using a stable hash of its identifier, and keep the assignment for the whole test. Randomizing per request lets the same person see both rankers, so the effect of one leaks into the other, and heavy users count unevenly.
Before looking at any metric, run a split check. Suppose an experiment is designed to split 100,000 accounts evenly and the result is 50,500 and 49,500. A chi-squared test on those counts gives a statistic of 10 and a p-value of about 0.0016 (illustrative counts).1 That is too unlikely to be chance, so you hunt for the bug first: a crash in one arm, bot traffic, lost logs.
You now know the experiment is sound or not. Only then do the metrics mean anything.
Step 2: Fix one primary metric and the guardrails before launch
The overall evaluation criterion (OEC) is the single metric, or one fixed combination of metrics, that decides whether the new ranker ships. Choose it before the test starts so no one picks the flattering number afterward.
Clicks alone mislead. A ranker can raise click-through rate by making results worse, because users click more to find what they wanted. A sturdier primary metric counts successful sessions per user, for example sessions that end in a long watch or a completed purchase.
Then list guardrail metrics: latency, complaint rate, revenue, and the diversity of what is shown. Write down the decision rule too: ship if the primary metric rises by at least the minimum worthwhile amount and no guardrail drops beyond its limit. A written rule stops post-hoc storytelling.
Step 3: Size the test and run whole weeks
Statistical power is the chance that a test detects a real effect of a chosen size, and the minimum detectable effect is the smallest change worth detecting. Together with the baseline rate and the significance level, they set how many users each arm needs.
Size the test on a per-user yes/no metric, so each account is one trial. Take a baseline where 10% of users have a successful session, a 5% significance level and 80% power (all illustrative). Detecting a relative lift of 10% needs about 14,700 accounts per arm. A 5% lift needs about 57,800, and a 2% lift about 356,300.1 Halving the lift needs about four times the users, so the smallest lift worth shipping sets the cost.
| Relative lift to detect | Users with a successful session (baseline 10%) | Users per arm (about) |
|---|---|---|
| 10% | 11.0% | 14,700 |
| 5% | 10.5% | 57,800 |
| 2% | 10.2% | 356,300 |
If the metric is a ratio such as clicks per impression while you randomize by user, the variance must be computed per user (the delta method or a per-user metric), or the test looks more precise than it is.
Divide the required users by daily eligible users, then round the duration up to whole weeks, because behavior differs between weekdays and weekends. The sizing rests on the normal approximation from the Gaussian distribution.
Text description of the diagram
- At a 10% relative lift the test needs about 14,700 accounts per arm.
- At a 2% relative lift the test needs about 356,300 accounts per arm.
Step 4: Read the result once, at the planned end
Read the result once, at the planned end, because every extra look raises the false-positive rate. If you test five times during a run and stop at the first "significant" result, a change with no effect at all is declared a winner in about 14% of runs, not 5%.1
Fix the sample size and the end date in advance and report at that point. If the business needs early looks, use a sequential method built for repeated checks and decide the rule before launch.
At the end, report the estimated effect with its confidence interval, not only a pass or fail. Check every guardrail. A t test or a similar test supplies the interval for a mean metric; for per-user metrics where a few heavy users dominate the mean (see mean vs median), cap extreme values or use a per-user variance-reduction method such as controlled-experiment using pre-experiment data (CUPED). Then decide by the rule you wrote in Step 2.
Step 5: Use interleaving first when many rankers wait
Interleaving can prune many candidate rankers faster than a standard A/B test. It is an optional stage that runs before the A/B test, not after it. A Netflix Technology Blog post (November 2017) describes a two-stage process. The first stage is a fast pruning step with interleaving. The second is a traditional A/B test on the few survivors, which measures longer-term behavior. The same post says the first stage finishes in a matter of days. The method follows Chapelle et al..
In team-draft interleaving, the rankers draft in rounds. In each round a coin toss decides which ranker picks first, and each ranker contributes its highest-ranked item not yet in the list. Illustrative example: ranker A orders items a, b, c, d and ranker B orders b, e, a, f. If A wins both tosses, the blended list is a, b, c, e, and the contributors are A, B, A, B. If the user clicks b, c and e, B gets two credits and A gets one.1
The coin toss matters because lower positions get fewer clicks, so each position should be equally likely to come from either ranker. Interleaving measures preference, not retention, so the survivors still need an A/B test.
Step-by-step description
- Randomize by user, then check the split.
- Primary metric and guardrails come first.
- The smallest worthwhile lift sets the size.
- Read at the planned end only.
- Many rankers? Interleave before step 1.
- Randomize by user so each person sees one ranker.
- Check the split before reading any result.
- Read the result once at the planned end.
Knowing it is half the job. Saying it is the other half.
Interview Clozo is an AI interview copilot for real interview rounds: it hears the question and puts a strong answer on your screen, and you say it in your own words. See the features or how it works.
Start Free Trial →The Staff-level answer
How would you design an A/B test for a new ranking algorithm?
I would randomize by user, so each person always sees one ranker, and keep the current ranker as control. Before launch I fix one primary metric, say successful sessions per user, plus guardrails such as latency and complaint rate, and I size the test from the smallest lift worth shipping. After launch I first check the split for sample ratio mismatch, then run whole weeks and read the result once at the planned end. If many candidate rankers are waiting, I use interleaving first to prune them, then A/B test the survivors on the long-term metrics.
What makes it Staff-level: it names the unit of randomization, the check that protects the result, and a way to cut the cost of testing many rankers.
The rubric
| Dimension | Weak answer | Strong answer | Staff answer |
|---|---|---|---|
| Correctness | Splits requests at random | Randomizes by user | Also checks the split before any metric |
| Depth | Compares click-through rate | Primary metric plus guardrails | Explains why clicks alone mislead |
| Trade-offs | Ignores test duration | Sizes from the smallest worthwhile lift | Runs whole weeks, states the cost of small lifts |
| Communication | Lists steps with no order | States design, run and read phases | Gives the decision rule up front |
| Follow-up readiness | Stuck on "what if no effect" | Handles stopping and novelty | Proposes interleaving then A/B for many rankers |
Three variants of this question
What if the new ranker improves NDCG before launch but the A/B test shows no change?
Normalized discounted cumulative gain (NDCG) scores a ranking against labeled judgments or past logged clicks, neither of which is live behavior. Trust the online result for the ship decision. Then check whether the test was big enough, whether the metrics match what NDCG rewards, and whether the logged data carried position bias.
How would you test a ranker when users influence each other, such as in a marketplace?
Randomizing users can leak when users share limited inventory or compete, so one arm's gains come out of the other arm. Consider randomizing whole markets, or alternating the ranker over time blocks, and accept fewer independent units and a longer run.
How would you compare ten candidate rankers?
Use interleaving to prune the ten to a short list in days, as in Step 5, then run a standard A/B test on the survivors. Testing all ten as separate arms splits traffic ten ways and raises the chance that one wins by luck.
Common mistakes
- "I'll split requests 50/50." (wrong) One person then sees both rankers. (right) "I randomize by user and keep the assignment for the whole test."
- "I'll stop as soon as p drops below 0.05." (wrong) Repeated looks inflate false positives. (right) "I fix the sample size and read the result once at the planned end."
- "Click-through rate went up, so the ranker is better." (wrong) Worse results can raise clicks. (right) "I judge by a primary metric chosen in advance and check guardrails."
- "The pre-launch metric improved, so it will win online." (wrong) That metric reflects past logged behavior. (right) "The online test decides; the pre-launch metric only picks candidates."
- "Interleaving replaces the A/B test." (wrong) It measures preference, not long-term outcomes. (right) "Interleaving prunes; an A/B test confirms."
Follow-up questions
What metrics would you use to evaluate a ranking algorithm?
Pick one primary metric tied to the goal, such as successful sessions per user, and add guardrails for latency, complaints and revenue. Use click-through rate as a diagnostic, not the decision metric.
How long should you run the A/B test?
Long enough to reach the planned sample size, rounded up to whole weeks so every weekday appears equally. The smallest lift worth detecting drives the length; see the sizing table in Step 3.
What is sample ratio mismatch and how do you detect it?
Sample ratio mismatch is a gap between the designed and observed group sizes. Compare the observed counts to the designed split with a chi-squared goodness-of-fit test, and investigate assignment and logging when it fails.
What is the novelty effect?
Users may click a changed ranking more at first because it is new, and the lift can fade. Run for weeks and check whether the daily effect is shrinking before you trust it.
Should you randomize by user or by request?
By user, so each person sees one ranker and repeated visits stay independent of the other arm. More practice on this family of prompts is in the probability interview questions.
- Randomize by user and keep the assignment fixed for the whole test.
- Write the primary metric, guardrails and decision rule before launch.
- Size from the smallest worthwhile lift; halving the lift roughly quadruples the users.
- Run whole weeks and read once, or use a sequential method designed for repeated looks.
- Use interleaving to prune many rankers, then confirm survivors with an A/B test.
Sources
- Innovating Faster on Personalization Algorithms at Netflix Using Interleaving — Netflix Technology Blog (Parks, Aurisset, Ramm), 29 Nov 2017
- Large-scale validation and analysis of interleaved search evaluation — ACM Transactions on Information Systems (Chapelle, Joachims, Radlinski, Yue), 1 Feb 2012