SYSTEM DESIGN SKETCHBOOK / PRACTICE SHEET / NO. 29
Design an A/B testing platform
Product teams want to try a new checkout button, a different ranking model or a cheaper image format on a slice of users and know whether it helped. They set up an experiment in a console, the apps and services pick it up, and a few days later the team reads results they can trust enough to ship or roll back.
Requirements
- Define an experiment with variants, a traffic percentage, targeting rules (country, platform, app version) and the metrics it is judged on.
- Assign each user to a variant deterministically, so they see the same variant on every request and every device they are signed in on.
- Record an exposure when a user actually encounters the experiment.
- Report each variant's effect on its metrics with confidence intervals, and stop a variant automatically if it badly hurts a guardrail metric such as crash rate.
Constraints and assumptions
- 100 million daily active users; backend services make about 10 million variant decisions per second at peak.
- About 1,000 experiments run at once; a request may touch 20 of them.
- A variant decision must add under 1 ms and must keep working if the experiment service is down.
- Config changes (start, ramp, stop) take effect everywhere within 1 minute.
- Business metrics (purchases, sessions, crashes) already land in an event warehouse; daily results are fine, guardrails need a check every 15 minutes.
Out of scope for the first sketch
Multi-armed bandits and automatic traffic optimization · The visual editor for building variants · Feature flag permissions and audit workflows
Draw your design
Rough math and notes
SYSTEM DESIGN SKETCHBOOK / FOLLOW-UPS
Design an A/B testing platform
Finish your first sketch before answering these. Cross out freely.
- How do you assign users without storing an assignment per user, and how do you stop two experiments on the same page from interfering with each other?
- A team ramps treatment from 10% to 50% of users. Which users change groups, and what happens to the analysis?
- Why does it matter whether you log an exposure when the variant is decided or when the user actually sees it? How would you notice that logging is broken?
- A variant raises the crash rate. How do you detect it within 15 minutes and stop it, without stopping healthy experiments on noise?
- A visitor starts an experiment logged out and then signs in. Which variant do they get, and how is that counted?
Compare afterwards: worked approaches and reading at sketchbook /questions/ab-testing-platform/review