KatInterview

Feature Flag Delivery and Live Experiment Metrics at Scale

System DesignModel answer
HardModel answerSystem Designsystem-designfeature-flagscdn

Last updated

Design a system that ships versioned feature flags to 10M devices with fast global rollback, plus a streaming pipeline that computes per-version click-through rates in near real time.

Problem

A large consumer streaming app controls its behavior with thousands of remotely managed feature flags. Teams use them for staged launches and A/B experiments. Design the two cooperating subsystems below.

1. Flag delivery service

Publishes flag changes to millions of devices. It must:

  • version every change,
  • support gradual exposure (for example 5%, then 25%, then 100%),
  • support a global rollback that takes effect almost immediately.

2. Engagement telemetry pipeline

Ingests impression and click events from devices and computes near-real-time click-through rate (CTR) for each flag version, so a bad rollout can be detected quickly.

Requirements

  • Scale: 10 million devices online at once, each either polling or being pushed config. About 500,000 telemetry events per second worldwide.
  • Consistency: Devices must converge on a consistent config within a bounded window. A rollback must reach all devices in under 30 seconds.
  • Storage: Config payloads are small JSON documents. Telemetry must feed real-time dashboards and be retained for 30 days.

What to cover

  • API design: the calls a device uses to fetch config and to upload events, plus the admin-side calls.
  • Data model: how config versions are stored, and how each event is tied to the config version that produced it.
  • Architecture: the full path from an admin change to a device, and from a device event to an aggregated CTR number.
  • Trade-offs: how you prevent a thundering herd when a config changes, and how you balance freshness against correctness in the telemetry aggregates.

State your assumptions and back-of-the-envelope numbers, and mention failure modes.

Hints

Hint 1

Do the arithmetic first: 10M devices polling every ~15s is hundreds of thousands of requests per second. What kind of serving tier makes that cheap, and what property must the response have?

Hint 2

Consider shipping the rollout rule (percentage plus salt) rather than per-device decisions, so every device downloads identical bytes and a ramp from 5% to 25% keeps earlier users in treatment.

Hint 3

Make snapshot IDs monotonic and treat rollback as a new snapshot with old content. Then think about how events carry the flag version and variant, and how to avoid hot keys and double counting in the stream job.