AlgoViz

Design an A/B testing platform

hard 45 min

Show 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

AppSDKin the appCDN edgeconfig fileConfig serviceIngest

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

AppsIngestKafkaWarehouseraw, 90 daysPerson-days240M a dayFirst exposuresup to 1BStats engineResults2M rows

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

    critical

    The first 10% all get the same version.

    Wrong
    b = bucket(salt, unit)in_test = b < 1000v = "A" if b < 5000 else "B"
    Right
    in_test = bucket(t_salt, unit) < 1000v = "A" if bucket(v_salt, unit) < 5000 else "B"
  • Counting ineligible people as control

    critical

    Control then holds people whom treatment can never have.

    Wrong
    if not target(user):    return log("control")
    Right
    if not target(user):    return default        # no exposure
  • Stopping on the first good day

    major

    Many looks, many false alarms.

    Wrong
    if p < 0.05: ship()
    Right
    if n >= planned and weeks >= 2:    decide(interval)
  • The random coin

    major

    The version flickers between pages.

    Wrong
    v = random.choice("AB")
    Right
    v = pick(split, bucket(salt, unit))
  • Changing weights in the middle

    major

    People change version and days mix different splits.

    Wrong
    exp.weights = [2000, 8000]
    Right
    exp.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.