Back to sketch

SYSTEM DESIGN SKETCHBOOK / PRACTICE SHEET / NO. 29

Design an A/B testing platform

Advanced · 45 min · Data pipelines & analytics

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

Done on paper? Compare with the worked approaches