MLOps Explained: Getting Machine Learning Models Into Production (and Keeping Them There)

What MLOps is and how to do it — reproducible training, experiment tracking, model registries, batch vs real-time serving, feature stores, drift monitoring and retraining.

By Danyal Ahmed - Data Scientist · · 5 min read

Industry surveys have long suggested that a large share of machine learning models never make it to production, and many that do quietly degrade until someone notices the predictions stopped making sense. MLOps is the set of practices that closes that gap: taking models from a notebook to a reliable, monitored production system, and keeping them healthy as the world changes.

Key takeaways

  • MLOps applies DevOps principles (automation, versioning, testing, monitoring) to the whole ML lifecycle, including data and models.
  • Make training reproducible: version code, data and configuration, and track experiments.
  • Choose batch or real-time serving based on how predictions are used. Batch is simpler and often sufficient.
  • Prevent training/serving skew with shared feature pipelines.
  • Monitor data drift, prediction drift and business outcomes, with a retraining strategy ready.

Why ML in production is different

Traditional software changes when code changes. ML systems change when code, data or the world changes:

  • The data distribution shifts (new customer segments, seasonality, a pandemic, a product change).
  • Upstream data pipelines break or change meaning.
  • The model's own predictions change user behavior (feedback loops).

A model that was accurate at launch can decay silently. MLOps is how you notice and respond.

The ML lifecycle

textProblem framing → Data → Features → Training → Evaluation → Deployment → Monitoring
        ▲                                                                  │
        └──────────────────────── Retraining / iteration ◀────────────────┘

1. Reproducible training

You should be able to answer: which code, data, features and hyperparameters produced this model?

  • Version code in git, including training scripts and feature logic.
  • Version data: snapshot training datasets or record exact queries plus data versions.
  • Track experiments: parameters, metrics, artifacts and environment for every run.
  • Pin dependencies and use containers for consistent environments.
  • Automate training as a pipeline, not a sequence of manual notebook cells.

2. Evaluation gates

Before a model is promoted:

  • Compare against the current production model and a simple baseline on the same held-out data.
  • Check metrics that matter for the business (classification metrics explained), not only aggregate AUC.
  • Check segment performance (regions, customer types) for regressions and fairness issues.
  • Run sanity tests: prediction ranges, behavior on edge cases, invariance tests (for example, changing a customer's name shouldn't change their risk score).

3. Model registry

A registry stores model versions with metadata (training data, metrics, lineage) and stage labels such as staging, production and archived. Deployment pulls a specific registered version, and rollback means pointing back to the previous one.

4. Serving: batch vs real-time

Batch prediction Real-time (online) prediction
How Scheduled job scores many records, writes results to a table API returns a prediction per request
Latency Minutes–hours Milliseconds
Complexity Lower Higher (availability, scaling, feature freshness)
Examples Daily churn scores, weekly demand forecasts, lead scoring Fraud checks at payment time, search ranking, recommendations on page load

Start with batch if predictions can be precomputed. It's simpler to operate, debug and monitor. Use real-time serving when predictions depend on information available only at request time.

Real-time serving patterns:

  • Model behind a REST/gRPC API in containers, with autoscaling (Kubernetes explained).
  • Embedded in an existing service for low latency.
  • Serverless endpoints for spiky, low-volume traffic (serverless explained).

5. Features and training/serving skew

If features are computed one way in training (SQL over historical tables) and another way in production (application code at request time), predictions silently degrade. Mitigations:

  • Shared feature code used by both training and serving pipelines.
  • Feature stores that provide point-in-time correct training data and low-latency online features.
  • Logging production features and comparing their distributions against training data.

More on features in the feature engineering guide.

6. Safe deployment

Treat model releases like software releases (zero-downtime deployments):

  • Shadow mode: the new model scores live traffic but its predictions aren't used. Compare against the current model.
  • Canary: route a small percentage of traffic to the new model, and watch metrics.
  • A/B test: measure business impact, not just offline metrics (A/B testing done right).
  • Instant rollback to the previous registered version.

7. Monitoring

Monitor at several levels:

Operational

  • Latency, error rates, throughput, resource usage.

Data quality and drift

  • Missing values, out-of-range features, schema changes (data quality guide).
  • Data drift: input distributions shifting from training (population stability index, KS tests, distribution distance metrics).

Prediction drift

  • Changes in the distribution of scores or predicted classes.

Model performance

  • Actual accuracy once ground truth arrives, which may take days or months (did the customer actually churn?).
  • Business KPIs the model is meant to move.

Alert on meaningful changes, and route alerts to owners with runbooks.

8. Retraining strategies

  • Scheduled: retrain weekly or monthly. Simple, and fine for slowly changing domains.
  • Triggered: retrain when drift or performance thresholds are breached.
  • Continuous/online: incremental updates for fast-moving domains. More complex, and needs strong safeguards.

Automated retraining still needs evaluation gates. Never auto-deploy a model that hasn't beaten the current one on held-out data.

MLOps maturity levels

Level Characteristics
0: Manual Notebooks, manual training, ad-hoc deployment, no monitoring
1: Pipeline automation Automated training pipelines, experiment tracking, registry, basic monitoring
2: CI/CD for ML Automated testing and deployment of pipelines and models, drift-triggered retraining, full lineage

Most teams should aim for level 1 quickly and grow toward level 2 as the number and criticality of models increase.

MLOps for LLM applications

Generative AI adds its own concerns, sometimes called LLMOps: prompt versioning, eval suites instead of single accuracy numbers (LLM evaluation guide), cost and latency tracking (LLM cost optimization), retrieval index freshness for RAG, and safety monitoring. The principles are the same: version everything, test before release, monitor in production.

FAQ

What's the difference between MLOps and DevOps?

DevOps manages code and infrastructure. MLOps extends it to data and models, which change independently of code and can degrade silently, so it adds data versioning, experiment tracking, model registries, drift monitoring and retraining.

Do small teams need MLOps?

They need the basics: reproducible training, a way to deploy and roll back, and monitoring. Heavy platforms can wait, but "a model someone trained on their laptop two years ago" is a risk at any team size.

How often should models be retrained?

It depends on how quickly your data and environment change. Monitor drift and performance, and retrain when they indicate degradation, or on a schedule matched to the domain's pace.

What is model drift?

Model drift is the decline in a model's performance over time, typically because input data distributions change (data drift) or because the relationship between inputs and outcomes changes (concept drift).