Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
Handoff, Measurement and Iteration  ›  Capstone Project

A/B Testing and Feature Flags

A/B Testing 15 minAn A/B test randomly splits people between versions and judges them by a decision rule fixed in advance, while feature flags control who sees which version and allow gradual rollout and instant switch-off.

A/B Testing and Feature Flags

The morning change window is ready, but one argument remains. The cooks' representatives want it to close at 7:00 a.m., for a safer buffer. The design team wants 7:30 a.m., which catches more late changes. The last lesson showed that comparing people who chose to use a feature cannot prove cause. So LunchLoop lets subscribers settle it through their behaviour, with a switch ready to undo everything if something breaks.

The rule

Fix the decision rule before the test; let the flag decide who sees what.

An A/B test splits people at random into groups, shows each group one version, and compares a metric chosen in advance. Random assignment makes the groups alike in every other way, so a difference in results can be credited to the change itself. That is what turns correlation into cause.

The rules that keep a test honest:

  • Decide before you start: one primary metric, the guardrails, and the size of difference that would change your mind.
  • Run long enough: work out the sample size you need in advance, and run in whole weeks so that every weekday is covered.
  • No stopping at the first good-looking result. Checking again and again and stopping the moment one version leads produces false wins.
  • Assign by person, not by visit, so each subscriber sees the same version throughout.

A feature flag is a switch in the code that turns a feature on or off for chosen people without shipping a new release. Flags let a team split traffic for a test, release gradually (5%, then 25%, then everyone), let staff try things first, and switch a feature off instantly if it misbehaves.

if (flags.isOn("change_window_730", subscriber.id)) {
  showChangeUntil("7:30 a.m.");
} else {
  showChangeUntil("7:00 a.m.");
}

Old flags are removed once a decision is final; forgotten flags turn into tangled code.

The shortcut

Write the decision before the data. "If B cuts untouched boxes by at least 1 percentage point and cook leftovers do not rise, we ship B; otherwise we keep A." If you cannot write that sentence, you are not ready to test.

Testing 7:00 against 7:30Step 1 of 5
  1. Write the decision rule

    Primary metric: untouched-box rate. Guardrail: leftover portions per cook per day. Ship 7:30 if it cuts untouched boxes by 1 point or more while leftovers do not rise.

Drills

Answer fast — trust the rule.

quick drill

Why must people be assigned to the A and B groups at random?

quick drill

Two days into a planned three-week test, version B looks 20% better. What should the team do?

quick drill

What does a feature flag let a team do?

quick drill

B cuts untouched boxes by 2 points, but cook leftovers double. Under the pre-written rule, what happens?

Remember

  • Fix the decision rule before the test; let the flag decide who sees what.
  • Shortcut: write "if the result is X, we do Y" before any data arrives.
  • Trap: stopping at the first good-looking result, and leaving old flags in the code.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainTest the meal photo

LunchLoop wants to test showing a photo of the meal on the Today card. Write the decision rule (primary metric, guardrail and threshold), describe how you would use a feature flag to run the test and roll out the winner, and explain one mistake that would make the result untrustworthy.