SysDesignAtlas

The ML Platform

Feature stores, training/serving skew, batch versus online inference, and drift monitoring — the classical ML infrastructure that still runs most production predictions.

HLDMedium11 min readaimlopsfeature-storeml-platform
Confidence

#Why this isn't obsolete

Language models get the attention. Meanwhile most production ML predictions are still gradient-boosted trees and small neural networks scoring tabular features: fraud decisions, ad ranking, credit scoring, demand forecasting, churn prediction, recommendation. They're cheaper, faster, more accurate on tabular data, and far easier to explain.

They also have an infrastructure problem language models don't: the input is computed, not given. An LLM receives text. A fraud model receives 200 features that someone had to compute, consistently, in two different places.

#Training/serving skew

A feature is one input the model reasons about — "average order value over the last 30 days", say. Skew is what happens when that number is computed one way during training and a subtly different way in production: the model was taught on figures it never actually receives. It is the defining failure mode of classical ML systems, and it fails silently, because both pipelines are working exactly as written.

   TRAINING                          SERVING

   Spark job over historical data    Python service, one request
   window functions, joins,          must compute the same feature
   full table scans                  from live data in <10 ms

   "average order value over
    the last 30 days"                same feature, different code,
                                     different data path
        ↓                                    ↓
   model learns from THIS            model scores THAT

   → any discrepancy means the model sees inputs at
     serving time that it never saw in training.

   Symptom: excellent offline metrics, disappointing
   production performance, and no error anywhere.

The discrepancies are usually mundane and invisible:

  • Training computes the 30-day average inclusive of the event day; serving excludes it.
  • Training uses a nightly snapshot; serving uses live data that's 4 hours ahead.
  • Training fills nulls with the column mean; serving fills with zero.
  • Timezone handling differs between the Spark job and the service.
  • A categorical value present in training data no longer exists, and the encoder maps it to a different index. Categories are fed to the model as numbers based on their position in a list, so if the list changes, "electronics" might arrive as category 4 instead of 5 — and the model reads it as a different category entirely.

#Feature stores

Feature definition declared once — transformation, source, entity, freshness Offline store columnar, historical, point-in-time correct · training Online store key-value, low latency · serving Materialisation batch and streaming jobs keeping both in sync
One definition, two materialisations, guaranteed consistent.

Point-in-time correctness is the offline store's essential and subtle job.

   Training example: a transaction at 2026-03-14 09:15

   ✗ WRONG — join to the CURRENT feature value
       "customer_lifetime_value" as of today
       → includes purchases made AFTER the transaction
       → the model learns from the future
       → offline AUC (a standard accuracy score) is
         spectacular, production is useless

   ✓ RIGHT — as-of join at the event timestamp
       "customer_lifetime_value" as it was at 09:15 on 14 March
       → exactly what serving will see

This is label leakage, and it is the most common cause of a model that performs brilliantly offline and fails in production. It's also the same problem as a temporal join in stream processing, and it requires the same machinery: a stored history of every value each feature has had, queried as of a timestamp ("what was this customer's lifetime value at 09:15 on 14 March?"), not a lookup of the current value.

The online store is a straightforward low-latency key-value problem — Redis, DynamoDB, or similar — with two demanding requirements: p99 under a few milliseconds (a scoring request may fetch 200 features), and freshness matching the feature's declared SLA — if the definition says "updated within 5 minutes", the online value must never be older than that.

Materialisation keeps them in sync. Batch features (daily aggregates) come from a scheduled job writing both stores. Streaming features ("transactions in the last 5 minutes") come from a stream processor writing the online store continuously, with the same computation logged to the offline store for future training.

#Batch versus online inference

BatchOnline
WhenScheduled — hourly, nightlyPer request
LatencyMinutes to hoursMilliseconds
CostLow; one big job is cheaper per prediction, and it can run on cheap interruptible "spot" machinesHigher; provisioned for peak
FreshnessAs of the last runCurrent
ComplexityLow — a job that writes a tableHigher — a service with SLAs
FitsChurn scores, recommendations, forecastsFraud, pricing, ranking, personalisation

Batch is underrated. If predictions don't depend on within-session behaviour, precomputing them nightly and serving from a key-value store is dramatically simpler, cheaper, and more reliable than a scoring service. Many "we need real-time ML" requirements are satisfied by hourly batch, and the honest question is what actually changes within the hour.

The hybrid is common and sensible: precompute a base score in batch, adjust it online with a handful of real-time features. You get most of the freshness benefit for a fraction of the online complexity.

#Drift

Models degrade because the world moves, and nothing errors when they do.

   DATA DRIFT        the input distribution changes
                     new customer segment, a new product line,
                     an upstream schema change
                     → detect: compare the spread of each feature
                       in production against training, and alert
                       when the shapes diverge

   CONCEPT DRIFT     the relationship between input and label
                     changes — fraud patterns adapt, user
                     preferences shift
                     → detect: only via labels, which lag

   LABEL DELAY       the fundamental problem: a chargeback
                     arrives 60 days after the transaction,
                     so you learn today's model is failing
                     in two months

   PREDICTION DRIFT  the output distribution shifts
                     → the earliest available signal, and it
                       needs no labels. Watch it.

Prediction drift is the practical monitor. If your fraud model's average predicted probability moves from 0.02 to 0.06 with no known cause, something changed — upstream data, feature computation, or the population. You get this signal immediately, without waiting for labels.

Feedback loops are the subtle hazard. A fraud model that blocks transactions never learns whether they were actually fraudulent. A recommender that only shows popular items only collects data on popular items. Both narrow over time. The standard mitigation is deliberate exploration — let a small percentage through unblocked, or show some randomised recommendations — accepting a known cost to keep the training data representative.

#The registry and lineage

Every model in production needs a traceable answer to: what data, what code, what features, what performance.

   model: fraud-scorer-v4
   ├── training data snapshot   (table format snapshot ID)
   ├── feature definitions      (versioned, with hashes)
   ├── training code commit
   ├── hyperparameters
   ├── offline metrics          (by segment, not just aggregate)
   ├── validation results
   └── approval record          (who signed off, when)

This is not bureaucracy. "Why did this model decline my loan?" is a legally answerable question in several jurisdictions, and answering it requires knowing exactly which model version scored the application, on which feature values, from which definitions. Reconstructing that after the fact without lineage is not possible.

The same snapshot and time-travel machinery that makes datasets reproducible is what makes this work.

#Serving patterns

  • Embedded model. Load into the application process. Lowest latency, no network hop; but it couples deployment of the model to deployment of the app — shipping a new model means redeploying the whole application.
  • Model server. A dedicated service (Triton, TorchServe, KServe). Independent deployment, better hardware utilisation, one network hop.
  • Serverless. Fine for low, spiky traffic; cold starts hurt.
  • Edge. On-device for privacy or offline operation; hard to update and hard to monitor.

For a small tree model, embedded is usually right — it's a few milliseconds of CPU and the operational simplicity is worth a lot. Model servers earn their keep for GPU-backed models or when many services share one model.

#Check yourself

Why is classical ML still most production prediction?Show answer
Gradient-boosted trees and small nets on tabular features are cheaper, faster, more accurate on tabular data and easier to explain — fraud, ranking, credit, forecasting, churn.
What is training/serving skew?Show answer
The same feature computed differently in training (e.g. a Spark job) and serving (a live service) — inclusive vs exclusive windows, snapshots vs live data, different null fills — so the model sees inputs it never trained on.
How do you eliminate skew?Show answer
Design it out: define each feature once in a feature store and materialise it to both offline and online stores. Diagnose by comparing logged serving feature distributions with training.
What is point-in-time correctness?Show answer
Joining each training example to feature values as they were at the event timestamp, not today's — otherwise label leakage teaches the model from the future and offline metrics lie.
Batch or online inference?Show answer
Batch (scheduled, cheap, simple, stale) suits churn scores and forecasts; online (per request, millisecond SLAs) suits fraud and pricing. A batch base score adjusted by a few live features is a common hybrid.
What kinds of drift exist, and which signal comes first?Show answer
Data drift (inputs change), concept drift (input–label relationship changes, seen only via lagging labels) and prediction drift — the output distribution shifting, available immediately with no labels.
Why do ML feedback loops narrow your data, and the fix?Show answer
A fraud model never learns about transactions it blocked; a recommender only learns about what it shows. Deliberate exploration — letting a small share through, or randomising — keeps data representative at a known cost.
Why is model lineage a legal requirement?Show answer
"Why was my loan declined?" must be answerable: which model version, data snapshot, feature definitions and values scored the application. Shadow-deploy before rollouts.

#What to carry forward

  • Classical ML still runs most production predictions, and its hard problem is that features must be computed identically in two places.
  • Training/serving skew is designed out, not debugged out — one definition, two materialisations.
  • Point-in-time correctness prevents label leakage, the top cause of great offline metrics and poor production results.
  • Batch inference is underrated. Ask what actually changes within the hour.
  • Prediction drift is the earliest signal and needs no labels.
  • Feedback loops narrow your data. Deliberate exploration is the cost of keeping it representative.
  • Lineage is a legal requirement, not paperwork. Shadow-deploy before every rollout.
00:00
/ 11m