Design a system to monitor a real-time prediction service for feature drift

production ML observability beyond accuracy checks.
async feature logging, distribution comparison via PSI/KS against training baseline, and threshold-based anomaly alerts.
What's really being asked
This question evaluates whether you understand that production ML systems fail silently when input distributions shift. Interviewers want to see you can separate inference from observability, choose appropriate statistical metrics, and design an alert mechanism that minimizes false positives without delaying detection. The core signal is architectural maturity: logging must not block prediction latency, comparisons must happen continuously rather than in ad-hoc notebooks, and thresholds must adapt to seasonality.
The full answer
First, the instrumentation layer. The prediction service should emit a structured event per request containing the feature vector, prediction timestamp, model version, and optional prediction confidence. These events flow asynchronously through a message bus like Kafka or Kinesis so the inference path stays under single-digit millisecond latency. Second, the reference store. You need an immutable profile of the training distribution, stored as histograms, quantiles, or parametric summaries per feature, versioned by model training run. Third, the drift computation engine. A separate consumer reads the stream in sliding windows, say five minutes or ten thousand requests, and computes univariate tests such as Population Stability Index, Kolmogorov-Smirnov, or Wasserstein distance for numerical features, and chi-squared for categorical features. Multivariate drift via autoencoder reconstruction error or maximum mean discrepancy is a bonus. Fourth, alerting logic. Use dynamic thresholds based on rolling z-scores or percentile bands rather than hard cutoffs, and route alerts through an on-call rotation with severity levels. A page triggers only after sustained drift across multiple features or windows, while a warning logs to a dashboard for review.
The mistakes people make
A red flag is proposing synchronous drift computation inside the prediction API, which adds unacceptable latency at scale. Another mistake is waiting for ground-truth labels before acting; feature drift is an input-level problem and must be caught before label delay, which can be days or weeks. Candidates also err by suggesting a single global threshold for all features, ignoring that sparse categorical features and dense numerical features behave differently. Finally, storing raw feature logs indefinitely in the hot path without sampling or TTL is an operational and cost anti-pattern.
What usually comes next
How do you handle high-cardinality categorical features? What is your sampling strategy if traffic is millions of QPS? How would you distinguish feature drift from legitimate seasonality? When would you trigger an automatic rollback versus just an alert? How do you monitor embeddings or unstructured inputs like text or images?
A concrete example
Imagine a fraud model using transaction amount and merchant category. The training reference shows transaction amounts are log-normal with a mean of 4.5 and standard deviation of 1.2. At deployment, the service logs every request to a Kafka topic. Every five minutes, a Flink job computes the KS statistic between the reference histogram and the current window. If the KS statistic exceeds 0.15 for two consecutive windows, a P2 alert fires in PagerDuty. The on-call engineer sees a dashboard showing the distribution shifted bimodal because a new merchant integration launched, prompting a feature engineering review rather than an immediate retrain.
Interview question
Which architecture best balances low inference latency with continuous feature drift detection?
- a.Run Kolmogorov-Smirnov tests synchronously within the prediction API before returning each response
- b.Apply a single hard threshold across all numerical and categorical features to trigger immediate on-call pages
- c.Emit feature vectors asynchronously to a stream processor that compares windowed distributions against a versioned training baseline using feature-specific thresholdsCorrect
- d.Log raw features to hot storage and run weekly batch jobs to compare against the original training CSV
Why? this is the answer
Asynchronous streaming keeps inference latency low while enabling continuous monitoring against a versioned baseline, and per-feature thresholds reduce false positives. Running synchronous tests inside the prediction API (A) adds unacceptable latency at scale and is a common anti-pattern.
Just read this? Test yourself on what you have been reading.
Read the original → datadoghq.com
- #mlops
- #machine-learning
- #monitoring
- #system-design
- #feature-drift
You just looked this up. Could you explain it out loud?
That is the part interviews actually test. Tezvyn takes questions like this one and gives you what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Open roles that interview on mlops — each one lists the topics its interview covers.
See open roles