KatInterview

Architecting an Enterprise Experimentation and Feature Flag Platform

System DesignModel answer
HardModel answerSystem Designsystem-designab-testingdata-pipelines

Last updated

Design a distributed, highly available A/B testing infrastructure capable of sub-millisecond variant evaluation, scale-proof event ingestion, and statistically sound automated analysis.

Scenario

Modern online platforms rely heavily on data-driven product decisions. Teams across product design, machine learning, financial risk, and growth continuously deploy experiments to evaluate user interface updates, pricing models, search ranking algorithms, and risk evaluation logic.

You are tasked with designing an enterprise-grade experimentation platform. The platform must safely route user traffic to target variations, log treatment exposures without introducing unacceptable latency or resource contention, and process conversion data to derive statistically robust insights.

Requirements

Core Capabilities

  • Experiment Administration & Target Distribution: Support flexible targeted rollouts based on user attributes (e.g., location, device type, risk category), distinct traffic splits (e.g., 90/10, 50/50), and mutually exclusive experiment groupings (layers) to allow parallel tests without cross-experiment interaction bias.
  • Deterministic Variant Routing: Given an entity identifier (such as user_id or device_id) and contextual attributes, compute the exact variant assignment deterministically. Assignments must remain consistent across sessions and user touchpoints.
  • Exposure & Data Ingestion Pipeline: Capture exact moments of exposure (when a user actually experiences a variant) and join these exposure logs with downstream transactional and telemetry events (e.g., checkout attempt, subscription renewal, default rate).
  • Statistical Analytics & Guardrails: Calculate conversion metrics, sample ratio mismatch (SRM) indicators, confidence intervals, p-values, and automated guardrail alerts.

System Constraints & Scale Targets

  • Evaluation Latency: In-process flag routing must complete within < 1 ms at p99, and central RPC evaluations must take < 10 ms at p99. Flag evaluation must never disrupt or block core transactional flows.
  • High Availability & Fault Tolerance: The evaluation pathway requires 99.999% availability (five-nines). System failures or network partitions must fail gracefully to default control options.
  • Scale:
    • 50,000 evaluation queries per second (QPS) standard load, peaking at 150,000 QPS.
    • 500 million incoming exposure and business telemetry events logged per day (~250 GB/day uncompressed data footprint).
    • Support hundreds of simultaneously running experiments across various front-end applications, native mobile apps, and back-end microservices.

Scope of Design

  1. System Architecture Breakdown: Clarify the distinction and responsibilities across Control Plane (experiment creation & rule distribution), Data Plane (in-process SDK evaluation & centralized edge fallback), and Analytics/Data Plane (telemetry processing & statistical analysis).
  2. Deterministic Bucketing Algorithm: Define how entities map to variants deterministically using uniform hashing mechanisms (e.g., salted Murmur3), rule predicate trees, and layered multi-experiment allocations.
  3. Event Stream Pipeline & Attribution: Show how exposure logs and downstream business events are captured, buffered, deduplicated, and linked for multi-window attribution.
  4. Data Modeling & Storage Strategy: Outline schema design and technology choices across relational metadata stores, streaming brokers, analytical data lakes, and OLAP querying engines.
  5. System Trade-offs & Edge Cases: Evaluate key design choices: Client/Embedded SDK vs. Remote Service Evaluation, push vs. pull config updates, and managing sticky variant integrity during traffic ramp-ups.

Hints

Hint 1

Avoid remote HTTP calls on the critical evaluation path; embedded local state and client-side deterministic hashing provide near-zero latency.

Hint 2

Use layer-based hashing (two-stage hashing) to maintain mutual exclusivity across simultaneous tests while preserving statistical independence across separate layers.

Hint 3

Strictly log exposures when the treatment is actually rendered/experienced by the user rather than when the feature flag configuration is evaluated.