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
Launch an experiment
Check a flag
Log events
Compute results
A guardrail trips
A retried batch
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
The numbers, at a glance
1 event ≈ 230,000/s4 checks ≈ 930,000/s
480 GBRaw events
30 GBDaily totals
under 1 GBResults
1% duplicates99% arrive once
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.
getVariant()
GET /assign, 4 ms
service down → apps break
+ Instant changes.− 2M calls a second on the request path.
first sight: INSERT user → B
every check: lookup
+ Any rule, easy lookup.− Billions of rows and a lookup per check.
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.
App
Assignment serviceWarehouse
Experiment DB
App + SDK
Config CDNCollectors
Experiment serviceEvent stream
Experiment DBWarehouse
App + SDK
Config CDNCollectors
Experiment serviceEvent stream
Experiment DBWarehouseMetric + stats jobs
App + SDK
Config CDNCollectorsGuardrail alerts
Experiment serviceEvent streamStream checks
Experiment DBWarehouseMetric + stats jobs
Was this walkthrough useful?Your vote tells us what to improve next.