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.
See it run
Decide a version without a call, ramp without moving anybody, turn events into a result, and see why looking early misleads.
Operations
One decision
Two hashes and a file. The network is not asked at the moment of the decision.
Step 1 of 8
Config arrives early
answer
304
version
811
The SDK asks the edge with its last ETag. Most answers are 304: nothing new.
Step 1: Config arrives early
def variant(key, default): exp = config.get(key) if not exp or exp.paused: return default if not target(exp, attributes): return default if not in_layer_range(exp, unit): return default if bucket(exp.t_salt, unit) >= exp.traffic: return default v = pick(exp.split, bucket(exp.v_salt, unit)) log_exposure(key, v, config.version) return v- Latency
- microseconds
- Load
- 40 KB file
- Config requests
- 3,470/s
- Peak (3x)
- 10,400/s
Every default return logs nothing: those people are not part of the test.
In the real world
The same a/b testing platform doing real jobs. Pick one and step through it.
80,000 in control and 78,000 in treatment, planned half and half.
Step 1 of 4
Treatment looks better
lift
+4%
Conversion is 4% higher. The team is pleased.
Step 1: Treatment looks better
Common mistakes
The bugs interviewers watch for, with the fix beside each.
One hash for traffic and version
criticalThe first 10% all get the same version.
Wrongb = bucket(salt, unit)in_test = b < 1000v = "A" if b < 5000 else "B"Rightin_test = bucket(t_salt, unit) < 1000v = "A" if bucket(v_salt, unit) < 5000 else "B"Counting ineligible people as control
criticalControl then holds people whom treatment can never have.
Wrongif not target(user): return log("control")Rightif not target(user): return default # no exposureStopping on the first good day
majorMany looks, many false alarms.
Wrongif p < 0.05: ship()Rightif n >= planned and weeks >= 2: decide(interval)The random coin
majorThe version flickers between pages.
Wrongv = random.choice("AB")Rightv = pick(split, bucket(salt, unit))Changing weights in the middle
majorPeople change version and days mix different splits.
Wrongexp.weights = [2000, 8000]Rightexp.traffic = 5000 # ramp who, not which
Interview tips
Split the problem
- Decide: local, stateless.
- Measure: hourly, careful.
- Stop: within a minute.
Do one sample size
- 16 p(1-p) / d^2.
- 3.2% and 5%: 193,600.
- It may end the discussion.
Show how it lies
- Ratio mismatch.
- Peeking: 23% at 14 looks.
- Exposure after drawing.
Know the limits
- Not significant is not no effect.
- People influence each other: assign groups.
- Bandits choose, tests measure.