08 · Monitoring and improvement

Monitoring and drift

9 min read

Monitoring is the set of measurements that tell a team a model in production has started behaving differently. They say so within an hour rather than a quarter. It watches four things, the service itself, the data going in, the predictions coming out, and the outcomes that arrive later, because a fault in any one of them looks like a bad model from the outside. The design decision is which numbers to watch, how fast each one can warn you, and what a person does when it does.

An everyday example

The manager of a clothing shop keeps an eye on four kinds of thing. The tills and the doors work. Deliveries arrive and the stock on the shelves is what the labels say. The staff make the recommendations they were trained to make, and the returns desk reports what came back, which it can only do weeks after the sale. A broken till shows within minutes, a bad delivery within a day, and a season of poor recommendations only when the returns pile up in March.

A prediction service has the same four layers, the service, the data, the predictions, and the outcomes, and the same gap between the fast signals and the confirmed ones. Where the shop and the service differ is visibility, because the manager can walk the floor and see a shelf of the wrong size. A model that has started returning the same ten items to everyone looks exactly like a healthy one until someone measures it, so every one of the four layers has to be measured on purpose.

Monitor four layers of the system

Service metrics say whether the machinery is running, and they include the response time, measured as the p99, meaning the time the slowest one in a hundred requests took, the error rate, how full the machines are, and how often the fallback path was used. Data metrics say whether the inputs look like the inputs the model was trained on, and they include missing fields, the age of each feature, values outside their allowed range, and shifts in the spread of values each input takes. Prediction metrics look at the outputs before anyone knows whether they were right, such as the spread of scores and the number of items flagged or shown. Outcome metrics are the ones the business cares about, such as precision, recall, click rate, or revenue, and they arrive only when the truth does.

Reading the layers side by side is what turns an alert into a diagnosis. A fast service with features that are 30 hours old points to a stalled data pipeline. A doubled review queue right after a threshold change points to the decision rule, and a fall in fraud recall with healthy machines and fresh data points to new behavior the model has not seen. The table below is the version of that reasoning a team writes on the wall.

Four layers, from fastest warning to confirmed truthService, Speed and errors, minutes. Data, Inputs seen, hours. Predictions, Scores going out, hours. Outcomes, Truth known, weeks. The left boxes warn fastest and the right box arrives last.Four layers, from fastest warning to confirmed truthServiceSpeed and errors,minutesDataInputs seen, hoursPredictionsScores going out,hoursOutcomesTruth known, weeks
The left boxes warn fastest and the right box arrives last.On a narrow screen, scroll the figure sideways to see every step.
Monitor four layers of the system
LayerExample signalFirst thing to check
ServiceThe p99 response time or the fallback rate risesCapacity and the health of each dependency.
DataFeature age or the share of missing values risesThe ingestion jobs and the feature store.
PredictionsThe number of items flagged doubles in an hourThe threshold, the model version, and the traffic mix.
OutcomesRecall falls on a cohort whose labels are completeLabel completeness, then a change in the inputs, then the failing groups of users.

A distribution shift is evidence to investigate

Drift is the word for the inputs changing shape over time, such as the average basket size rising from 40 to 55 dollars across a year. A second kind, sometimes called concept drift, is the relationship between inputs and outcomes changing, such as a basket of 55 dollars no longer being a sign of a returning customer. Seeing the first does not prove the second. Holiday traffic looks different from an ordinary week in every input and the model may still be doing fine.

A drift alert is a reason to look, and the first look is for breakage rather than for a changed world. A field that is suddenly empty, a price that switched from dollars to cents, or a category list with new spellings each produce a dramatic shift and a trivial fix, and retraining on that data would teach the model the bug. Statistical tests on millions of rows will flag a change too small to matter, so the alert threshold is set on the size of the shift and on whether it touches a feature the model leans on. The comparison is against a sensible reference week rather than against yesterday.

From a signal to a responseDetect, Freshness or shift. Localize, Version and users. Diagnose, Data, rule, or model. Respond, Repair or roll back. Most alerts stop at the third box with a data fix.From a signal to a responseDetectFreshness or shiftLocalizeVersion and usersDiagnoseData, rule, or modelRespondRepair or roll back
Most alerts stop at the third box with a data fix.On a narrow screen, scroll the figure sideways to see every step.

Separate fast warnings from confirmed quality

Outcomes arrive late, and the delay sets what monitoring can promise. A fraud label arrives when the cardholder disputes the charge, which can take up to 60 days, so a model that broke on the first of the month has its confirmed recall drop show up at the end of the second month. In those 60 days the only warnings are the fast layers, which is why a service and data check that fires within an hour matters more to the team than a perfect quality metric that fires in two months.

The predictions layer gives the earliest hint about quality. If 2 percent of transactions scored above 0.9 last week and 8 percent do today, four times as many customers are being blocked and someone should know before lunch, whatever the eventual labels say. When the labels do arrive, a cohort, meaning the group of predictions made in one week, is only judged when its labels are complete. Measuring recall on a week whose disputes have not yet come in makes the model look better than it is, and a broken join that drops outcome records makes it look worse.

Each prediction is logged with its model version, its feature versions, and the experiment it belonged to, so a change in any metric can be traced to the release or the pipeline that caused it. An alert is only useful when it names an action, such as rerunning a delayed job or switching back to the previous version. A threshold that fires twice a day with nothing to do is turned off by the people it was meant to help. Slow changes also need a weekly look, since fallback usage or the share of the catalog ever shown can creep for months without a single alert. When that look shows the model no longer fits the task, the next topic covers when and how to train a replacement.

What can be known, and whenMinute 5, Service errors visible. Hour 1, Score shift visible. Day 60, Labels complete. Day 61, Recall confirmed. Only the green points arrive in time to act on.What can be known, and whenMinute 5Service errorsvisibleHour 1Score shift visibleDay 60Labels completeDay 61Recall confirmed
Only the green points arrive in time to act on.On a narrow screen, scroll the figure sideways to see every step.
Last week, 2 percent of 1,000,000 daily transactions scored above 0.9 = 20,000 blocked
Today, 8 percent of 1,000,000 = 80,000 blocked
Four times the usual blocks, visible within the hour, 60 days before any label confirms it

Where people get confused

A drift alert gets treated as a retraining trigger. A shift in an input is a reason to look, and the look usually finds a broken pipeline or an expected seasonal change, neither of which a new model fixes. Retraining on data from a broken pipeline teaches the model the breakage.

Measuring quality on the most recent week is the next habit to lose. The labels for that week are incomplete, so recall looks higher than it will be, and a team that celebrates the number on Monday is disappointed in two months. Quality is measured on cohorts whose labels have finished arriving.

Adding alerts for everything defeats the ones that matter. An alert with no action attached trains the team to ignore the channel, and the one that mattered is missed. Each alert names the action, and the number of alerts per week is itself something the team watches.

In the interview

Interviewers use monitoring to see whether the candidate has thought past launch day, and it takes three to five minutes near the end of a design. Name the four layers in one sentence, then say which one warns fastest for this product and how long the outcome labels take to arrive. If asked how you would respond to an alert, walk the detect, localize, diagnose, respond row and offer the retraining question for the next topic rather than answering it here.

Interview questions

Feature distributions have shifted but measured quality is stable. Should you retrain now?

I would not retrain yet. First I would check whether the quality I am looking at is trustworthy, meaning the labels for that cohort have finished arriving, and then find which features shifted and for which users. The shift might be a holiday week, a change in the traffic mix, or a data bug such as a field that switched units, and retraining on a data bug would make the model worse.

If the shift is confirmed and quality holds, I would keep watching and let the regular retraining schedule pick up the new data. That means reacting a week later to a genuine change, which I would accept to avoid ever training a model on corrupted data by reflex.

What would you monitor on the first day this recommender is live?

On day one I would watch the service layer, meaning p99 response time against the 200 millisecond deadline, error rate, and how often the fallback list is served, and the data layer, meaning feature freshness and missing values, because those are the things that can break on launch day and they show within minutes.

I would also watch the predictions layer, such as the share of the catalog being shown and whether the same ten items dominate every page, because that shows a collapsed model hours before any click data confirms it. Click rate and retention I would judge only after a week, since a day of clicks is noise and the labels for longer outcomes are not in yet.

Recall has dropped. How do you know it is the model and not the pipeline?

I would rule out the pipeline first, because it is the commoner cause and the cheaper fix. I would check whether the drop lines up with a release or a pipeline change, whether feature age or missing values rose at the same time, and whether the outcome records themselves are complete, since a broken join that drops labels makes recall fall with nothing wrong in the model.

If the inputs are fresh and complete and the labels are whole, then the model is seeing behavior it has not learned, and I would look at which slices lost recall before deciding whether to retrain. A day spent checking plumbing before touching the model is cheaper than a retrain that learns a pipeline bug.

What to practice next

These problems let you measure the gap between training and serving inputs, compute a drift score between two weeks of data, and choose which metrics to alert on, which is the data layer of this topic.