Skip to content
SD-29 · Back to the write-up

Design a A/B Testing Platform

Assign in the SDK by hashing the user id, log exposures and events through a stream, and compute results from deduplicated daily totals per user.

Follow a request

Clients
Edge
Pipeline
Data and results
App + SDKHash, log, batch
Config CDNRules file
CollectorsStateless
Experiment serviceRules, results
Event streamBy user id
Stream checksGuardrails, SRM
Experiment DBDefinitions
Data warehouseEvents, totals
Metric jobsDedupe, stats
1app → collector · POST /events × 500Every 10 s the SDK sends a batch: the exposure, a purchase of €42, some screen views. Each has an event_id.1 / 3

The numbers, at a glance

For every event……there are about 4 flag checks
1 event ≈ 230,000/s4 checks ≈ 930,000/s
Data shrinks at each stepPer day, stored
Retries look like winsShare of events that arrive twice
Enough to fake a 1% lift, so every sum drops repeats by event_id first.

From a tap to a result

The check is local. Everything after the batch is off the app’s path.

App SDK
Config CDN
Collector
Event stream
Warehouse
Metric jobs
1 GET rules (304 most of the time)
2 rules v42
3 POST /events: exposure + purchase
4 append, key = user
5 2 copies written
6 202
7 bulk load, every minute
8 dedupe, sum per user
9 daily totals + exposures
RequestResponseAsync, does not block

Where assignment happens

The decision this question is really about.

Server per check
Too slow
getVariant()
GET /assign, 4 ms
service down → apps break
+ Instant changes.− 2M calls a second on the request path.
Stored assignments
Heavy
first sight: INSERT user → B
every check: lookup
+ Any rule, easy lookup.− Billions of rows and a lookup per check.
Hash in the SDK
Our pick
rules file in memory
hash(salt + user) mod 10,000
bucket 6,214 → Blog exposure once
+ 0.1 ms, stable, offline.− Changes take about a minute.

How it grows

Add a box only when a number forces you to. Highlighted boxes are new at each stage.

Stage 1 · ≈ 10,000 events/sMake it work
App
Assignment serviceWarehouse
Experiment DB
A server answers every check; every event is a row insert.
Stage 2 · ≈ 200,000 events/sAssign locally
App + SDK
Config CDNCollectors
Experiment serviceEvent stream
Experiment DBWarehouse
Rules file in the SDK; events through collectors and a stream.
Stage 3 · ≈ 500,000 events/sTrust the numbers
App + SDK
Config CDNCollectors
Experiment serviceEvent stream
Experiment DBWarehouseMetric + stats jobs
Dedupe, daily totals per user, statistics with an SRM check.
Stage 4 · 500,000 events/s, 1,000 experimentsGuard the users
App + SDK
Config CDNCollectorsGuardrail alerts
Experiment serviceEvent streamStream checks
Experiment DBWarehouseMetric + stats jobs
Guardrails every minute, automatic pause.
Was this walkthrough useful?Your vote tells us what to improve next.