Design an A/B testing platform
hard 45 minShow each person one version of a feature, always the same one, measure what they do, and say honestly whether the difference is real, for a thousand experiments at once.
Video lesson · Chapter 1 of 5
A green checkout button needs a trustworthy comparison
Theory
Read or listen first. About 2 min.
What it is
An A/B testing platform gives different people different versions of a product by chance, records what they do, and compares the groups. Because chance chose the groups, a large enough difference must come from the version.
It has two halves. One decides which version a person sees, in microseconds, everywhere. The other collects events and does statistics, in hours. They meet in one place: a record that says who was really shown what.
Why it exists
Comparing this week with last week mixes the change with everything else that happened: holidays, prices, weather. Two groups at the same time share all of that.
A platform also protects people from bad changes. A new version starts with 1% of them, and can be switched off in seconds.
A short history
2007
Kohavi, Henne and Sommerfield publish a practical guide to controlled experiments on the web at KDD.
2010
Google engineers describe overlapping layers, which let many experiments share the same traffic.
2013
Deng, Xu, Kohavi and Walker describe CUPED, which uses data from before an experiment to reduce noise.
December 2015
Johari, Pekelis and Walsh post a paper on always valid inference, for teams that look at results every day.
2019
Fabijan and others publish a guide to finding the causes of sample ratio mismatch at KDD.
Words to know
- Variant
- One version of the feature. The unchanged one is the control.
- Bucket
- A number from 0 to 9,999 made from a person's id.
- Salt
- Text added before hashing, so each experiment shuffles people differently.
- Exposure
- The record that a person reached the place where versions differ.
- Sample ratio mismatch (SRM)
- Group sizes that the planned split can hardly explain.
- Power
- The chance of noticing an effect of a given size, usually planned at 80%.
- Minimum detectable effect (MDE)
- The smallest effect the plan is able to notice.
- Guardrail
- A metric that must not get worse, such as errors or page time.
Solve it like an interview
New to it? Start with Approach. Revising? Go straight to the mock.
- 1ApproachWhat this question tests, where it gets hard, and how to spend the time.
- 2ScopeAsk what changes the design, then commit to a short list.
- 3NumbersWork out a number when the answer changes what you build.
- 4API and dataThe contract first, then the data that serves it.
- 5DesignStart with the smallest system that works. Change it only when something breaks.
- 6Deep divesCompare the options before you open them, then say which you would pick.
- 7Explain your choicesAnswer first. Then compare your reasoning.
- 8By levelThe same question is judged differently for mid, senior and staff.
- 9MockAnswer against the clock, then score yourself.
Understand it
The coin makes it fair, the ring keeps it steady, and the count of rings shows whether to trust it.
The task
What are we building?
A service like Optimizely, LaunchDarkly, Split, VWO, Statsig, Amplitude Experiment or Eppo. (Google Optimize was another; it closed on 30 September 2023.) Teams describe an experiment, the platform splits people, records results and reports them. Feature flags come with it, because a flag is the switch that an experiment turns.
Assign
Same person, same version, with no network call.
Record
Exposures and events, without losing or doubling them.
Judge
Effect, uncertainty, and whether the data can be trusted.
Control
Ramp up, exclude, hold out, and stop in seconds.
The hard part
Being believed
Every part can work and the answer can still be wrong: a missing exposure, a group that lost its slowest phones, a team that stopped on a lucky day. The hard part is building a pipeline that notices its own faults, at a thousand experiments at once.
The finished system
Where the design ends up
The whole system
Where each idea is taught
| Idea | Here | Full page |
|---|---|---|
| Config near users | One file at the edge | CDN |
| Events through a log | Exposures and events | Log-based queues |
| Windows over streams | Live guardrails | Stream processing |
| Scanning columns | Hourly statistics | OLAP |
| Counting an event once | Event ids | Idempotency |
| Counting clicks at scale | A neighbour problem | Ad click aggregator |
The Interviews page follows the nine tabs: Approach, Scope, Numbers, API and data, Design, Deep dives, Explain, By level and Mock.
Summary
The whole topic in one minute.
Assignment is a pure function of a person's id and the experiment's salt, so no server has to remember it. One hash decides whether the person is in the experiment, and another decides the version. The SDK evaluates both locally, from a config file.
Results are only as good as the exposure record. Check the sample ratio before you look at any metric, fix the sample size or use a method that allows peeking, and correct for many metrics. Stop harmful versions with fast guardrails, which are separate from the hourly statistics.
- Assignment is a hash, not a stored row: nothing to look up, nothing to lose.
- Use one hash for who takes part and another for which version, or ramping breaks the split.
- Record exposure where versions differ, in both groups, in the same way.
- Look at the sample ratio first. If it is off, show no result.
- Choose the sample size, or a method made for daily looking, before the start.
Sources
- Kohavi, Henne, Sommerfield: Practical guide to controlled experiments on the web (KDD 2007)
- Google: Overlapping experiment infrastructure (KDD 2010)
- Deng, Xu, Kohavi, Walker: CUPED (WSDM 2013)
- Johari, Pekelis, Walsh: Always valid inference
- Fabijan and others: Diagnosing sample ratio mismatch (KDD 2019)
- MDN: sendBeacon
- Google Optimize, sunset notice