Architecture Intermediate
A/B Testing Backend¶
A/B TestingExperimentsAnalytics 3 min read
Server-side A/B testing. Assignment, tracking, statistical significance.
Architecture¶
An A/B test = feature flag + tracking + analysis. The user is deterministically assigned to a variant.
function assignVariant(userId, experimentId) {
const hash = murmurhash(\`\${experimentId}:\${userId}\`);
const bucket = hash % 100;
// 50/50 split
return bucket < 50 ? 'control' : 'treatment';
}
app.get('/api/checkout', (req, res) => {
const variant = assignVariant(req.userId, 'checkout-v2');
trackExposure(req.userId, 'checkout-v2', variant);
if (variant === 'treatment') return renderNewCheckout(req, res);
return renderOldCheckout(req, res);
});
Tracking and Analysis¶
- Track exposure (who saw the variant) and conversion (who converted)
- Statistical significance — at least 2 weeks, thousands of users
- Tools: GrowthBook, Optimizely, custom solutions
Summary¶
A/B testing requires statistical discipline. Deterministic assignment, proper tracking, and sufficient data for decision-making.
Need Help with Implementation?¶
Our team has experience designing and implementing modern architectures. We’re happy to help.