ML Systems Lab Open interactive version →
Intermediate 29 min read MLOpspipelinesorchestrationAirflowidempotency

ML Pipeline Architecture

Batch vs streaming ingestion, orchestration, idempotency, pipeline failures

A team has a training script, a deployment script, and a cron job. They call it "the pipeline." Six months later nobody can say which data the live model was trained on. The training script hard-codes a local file path that broke when they moved to the cloud. The last model update took a week of manual fiddling to reproduce. That isn't a pipeline — it's a pile of scripts held together by memory that is quietly fading as people forget and move on.


What a real pipeline is: eight stages, end to end

*Ingestion* pulls the data, checks the schema, and writes a versioned snapshot. *Feature engineering* runs reproducible transforms into versioned tables. *Training* is pinned to a data version, hyperparameters, and a random seed, producing a versioned artifact. *Evaluation* scores it on a fixed holdout and compares to the current production model. *A deployment gate* auto-promotes if it clears the bar, or routes to a human if not. *Serving* looks up the model, computes online features, logs predictions. *Monitoring* watches drift and performance. *A retraining trigger* — on a schedule or an event — kicks the whole loop off again.


Three properties separate infrastructure from debt

*Idempotency:* re-running a step on the same input gives the identical output, no duplicates — done with fixed seeds, content-hashed data, and atomic overwrites. *Fast-fail on bad data:* check availability and schema *before* any compute runs — for example, if an outage cuts the upstream feed off mid-afternoon and training starts anyway on just the first 60% of that day's rows, the model learns a skewed slice missing an entire segment of the day's traffic (evenings, say) and deploys with full confidence in that skew; a model trained on a truncated, unrepresentative slice like that is worse than staying on the current model, which was validated on a complete day. *Complete lineage:* every artifact traces back to its exact data version, code commit, and parameters — without it, debugging is archaeology, and you cannot roll production back to the last model trained before a bug was introduced, because you do not know which models that bug touched.

The orchestrator you pick (Airflow, Prefect, Kubeflow, Metaflow) matters far less than whether it enforces those three.


The real test. Training and deployment are just two of the eight stages; without the other six you have technical debt dressed up as a system. So ask one question: can a new person reproduce the current production model from scratch, deterministically, in under two hours, without asking anyone? If yes, you have a pipeline. If no, you have scripts — and a week-long reconstruction waiting for you at the worst possible moment.

Key points

Takeaway

A pipeline that reports success tells you nothing about whether it produced correct data — the gap between "ran without errors" and "produced correct outputs" is exactly where silent bugs live, and only data quality assertions on pipeline outputs close it.

Recap

Check your understanding

Q1. Your daily retraining pipeline fails on day 3 because the upstream data source was unavailable. Select the two correct design choices for handling this gracefully.

Q2. You need to ensure that if a feature computation step fails and is rerun, it does not create duplicate records in your feature store. How do you design this?

Q3. A model is retrained daily. You discover that 4 days ago, a bug was introduced in the feature computation that corrupted 3 features. What is the remediation process?

Q4. What is the difference between a pipeline failure and a pipeline bug, and why does this distinction matter for ML systems?

Try it interactively

ML Systems Lab is a free interview-prep platform for ML engineers — work through the full interactive module, quizzes, and drills.

Open ML Systems Lab →