Preparing your design workspace

Loading the problem and your latest saved attempt…

Train a Click Model from Multiple Live Streams

Join live exposure, click, and item-feature streams into mature labels and release reproducible incremental model updates.

Problem statement

An original-author Google L5 interview report says an ML/design round asked for a model trained on live data from multiple streams. It does not name the learning objective, stream schemas, timing, scale, or update policy. The click-prediction task and every numerical target below are authored exercise assumptions.

A separate pseudocode request for MapReduce backpropagation in the same round is outside this system-design exercise.

For this exercise, assume a content service predicts whether an eligible impression will be clicked within ten minutes. Three independent event streams supply impressions, clicks, and item-feature changes.

Impressions and clicks carry stable event IDs, impression ID, item ID, event time and a coarse, non-identifying user cohort; feature changes carry item ID, event time, feature version and values. The model must use only features available as of the impression event, not later popularity or click outcomes.

A valid matching click can finalize a positive once joined; an impression is a negative only after its ten-minute response window and permitted lateness have closed. Duplicate, late and out-of-order delivery is normal.

Design the live ingestion, event-time join and label maturation, reproducible training snapshots, incremental model-update policy, offline and online evaluation, and versioned prediction path.

Do not build the content candidate generator, billing system, full personalization profile, or a general stream-processing product. Exclude raw user identifiers from the training record; preserve source and feature lineage so a corrected stream can be replayed without silent double training.

What to build

  1. Accept and durably identify authorized impression, click and item-feature events with schema validation and retry-safe outcomes.
  2. Create reproducible positive or matured-negative examples with as-of-impression features, explicit late/correction policy, and no double contribution from replay.
  3. Use newly finalized examples to propose a versioned model update, compare it to the approved baseline on a fresh sealed later-time cohort for each release decision, and activate only an approved package.
  4. Return a click probability with model and feature versions and a clear fallback or unavailable outcome when live inputs are stale or the active package fails.

At scale

  • For this exercise, assume peaks of 20,000 impressions, 2,000 clicks, and 5,000 item-feature updates per second, plus 20,000 prediction requests per second. Events may arrive up to two minutes late; clicks may occur within ten minutes after an impression.
  • For this exercise, a valid matching click may finalize a positive as soon as it is durably joined with as-of features. Finalize a non-click only when the click-stream event-time watermark passes the impression time plus ten minutes; the two-minute lateness allowance makes that roughly twelve minutes after exposure during healthy delivery. A healthy accepted event should appear in an eligible training snapshot within 30 minutes after its label finalizes; no provisional negative may be trained as final.
  • For this exercise, serve predictions within 100 milliseconds p95 with a pinned model/feature contract. Train candidate updates as mature data arrives but activate at most one release per day. Each release decision uses a fresh sealed later-time cohort; an exposed result becomes diagnostic only. Require that cohort log loss to worsen by no more than 0.01 absolute against the current approved model, and report calibration plus cohort slices. A reported product lift is monitored but not inferred from offline log loss alone.
  • For this exercise, retain replayable raw events seven days, versioned training examples thirty days, and model/evaluation/source-position lineage one year. A published model is immutable; rollback selects an earlier approved package rather than overwriting weights.