MLOps for the Software Engineer
Overview
A machine learning model is carefully trained. It passes all tests. Accuracy looks solid: 94%. You ship it to production on a Tuesday.
By Friday, it's making terrible predictions. Your support team is flooded with complaints. Users are getting wrong recommendations. The model that was so accurate in the lab has become a liability in the wild.
Why? The data changed. User behavior shifted. The world your model was trained on doesn't exist anymore. And worse, you had no idea this was happening until customers told you.
This is the core problem of machine learning: models degrade silently. Traditional software either works or it doesn't. But ML systems work until they don't, and the failure mode is subtle degradation, not a crash.
That's where MLOps comes in. MLOps is the discipline, infrastructure, and practices that let you treat machine learning models like production software: versioned, monitored, tested, deployed with confidence, and maintained throughout their lifecycle.
If you're building any system with ML at its core, you need MLOps. Without it, you're gambling.
Why ML Systems Are Fundamentally Different
The Code-Data Problem
Traditional software has one artifact that matters: code. If the code is correct, behavior is predictable. ML systems have two: code and data. The code can be perfect, but if the data changes, the model fails. You can't catch this with traditional testing because your test data is static, while production data evolves constantly.
A recommendation model trained on Q4 user data makes different decisions than the same model in Q1. A churn prediction model trained on stable user cohorts breaks when you acquire a new customer segment. A fraud detector trained on historical fraud patterns misses new attack vectors. The model itself hasn't changed. The data it operates on has.
Silent Failures and Degradation
Software bugs crash. They throw errors. They fail loudly. ML model degradation is silent. Your model might be 5% less accurate today than yesterday. Or it might be making systematic mistakes on a subset of inputs. You won't know unless you're actively measuring performance in production.
This is dangerous because degradation compounds. A model that's 1% worse each week becomes unusable in two months, and your users feel it the whole time.
The MLOps Mindset: Don't deploy a model and hope it keeps working. Deploy it, monitor it constantly, retrain it automatically, and version everything so you can roll back instantly if something breaks.
Probabilistic Behavior
Traditional software is deterministic. Given the same input, it produces the same output every time. ML models are probabilistic. They produce probability distributions. A model might be 92% confident in its prediction, or 64% confident. You need to understand and handle that uncertainty.
This means you need confidence thresholds, fallback logic, and explicit handling for cases where the model isn't sure. You can't just return the model's output and hope for the best.
The MLOps Pipeline: From Data to Production
Data Collection and Labeling
This is where most MLOps complexity lives, though teams rarely admit it. You need data. Lots of it. But more importantly, you need good data, labeled correctly, representative of what you'll see in production, updated as the world changes.
Data collection is an ongoing process, not a one-time thing. You're constantly gathering new examples, labeling them, versioning them. Teams that skip this and try to build models on small, static datasets end up with models that don't generalize.
Practical step: invest in data infrastructure. A data pipeline that logs raw events reliably is worth 10x what you'll spend building it.
Feature Engineering and Preparation
Raw data is usually wrong for models. You need to transform it: normalize distributions, handle missing values, engineer new features, deal with outliers. This is 80% of MLOps work. Not the exciting part, but the necessary part.
The critical MLOps practice here is: feature versioning. If you compute a feature today and it goes into a model, you need to be able to compute the exact same feature tomorrow with production data. Many teams don't track how features were computed, and their models break when feature logic drifts.
Model Training and Experimentation
You train multiple candidate models on your data. Compare them. Pick the best one by some metric (accuracy, AUC, F1, whatever matters for your problem). Version the winning model. Store its hyperparameters, training data version, and feature version.
The MLOps practice: use tools like MLflow, Weights & Biases, or Neptune to track every experiment. Which data version? Which features? Which hyperparameters? Which metrics? This metadata is what lets you reproduce results or rollback to a previous model if needed.
Validation and Testing
You validate on held-out data. But here's the critical insight: held-out test data is a snapshot from the past. It doesn't tell you whether your model will work on future data. So validation has two parts: traditional metrics on historical data, and ongoing monitoring on production data to catch degradation.
Deployment
Your model needs to: respond fast (
Deployment Checklist: Before you push a model to production: Can you rollback instantly? Can you serve two models simultaneously during a transition? Is there fallback logic if the model fails? Are you monitoring prediction latency? Are you tracking prediction confidence?
Monitoring and Alerting
You must monitor: prediction latency (is inference getting slower?), prediction volume (did traffic patterns change?), prediction confidence (are you getting less confident?), data drift (is the input data distribution shifting?), model drift (is accuracy degrading?), and prediction errors (are specific classes failing?).
Alert on thresholds. "If accuracy drops below 90%, page someone." "If latency exceeds 200ms, escalate." "If data drift exceeds threshold, trigger retraining." Make monitoring automatic and actionable.
Retraining and Continuous Improvement
Models degrade. So you retrain on fresh data. The question is: how often? Some teams retrain weekly. Some monthly. Some quarterly. Depends on how fast your data changes.
Ideal state: automatic retraining. Every night, retrain a candidate model on the latest data. If it outperforms the current model, deploy it. If not, keep the old one. This requires infrastructure, automated pipelines, automated validation, automated deployment, but it's the only way to keep models working over time.
Implementing MLOps: The Practical Framework
Version Everything
Not just code. Version your data (every training dataset is immutable and tagged). Version your features (exactly how you computed them). Version your models (model artifacts, hyperparameters, training metadata). Version your configurations (which model is in production? What inference settings?).
Use Git for code. Use DVC (Data Version Control) or similar for data. Use MLflow or similar for model artifacts. The result: you can always answer "Why did we deploy this model? What data and features were used? Can we reproduce it?" If you can't answer those questions easily, you don't have MLOps.
Automate the Pipeline
The flow should be: new data arrives → features computed → model trained → model validated → if better, deployed. All automatic. Zero human intervention. This requires orchestration tools like Airflow, Kubeflow, or GitHub Actions configured as a pipeline.
Most teams start manual. Someone runs a training script every week. This doesn't scale and introduces human error. Automate early.
Separate Training and Serving Environments
Your training environment is heavy: GPUs, big memory, distributed compute. Your serving environment is lightweight: just enough to run inference fast and handle your request volume. They're different architectures.
This matters for MLOps because you need to: train models in the heavy environment, package them cleanly, and deploy them to the lightweight serving environment. Many teams don't manage this boundary well and end up with serving systems that are bloated or models that can't run on their inference infrastructure.
Monitor Everything, Act on Alerts
Monitoring isn't optional. It's your early warning system. Without it, you're flying blind. Set up dashboards. Track the metrics that matter. Create alerts. And crucially: have a playbook for responding to alerts. "If accuracy drops, here's what we do: 1) validate the alert, 2) check for data drift, 3) retrain on fresh data, 4) validate new model, 5) deploy if better."
Tools and Platforms for MLOps
MLflow: Open-source, tracks experiments, packages models, manages deployments. Works with any framework. Lightweight and flexible.
Kubeflow: Kubernetes-native ML platform. Good for teams already using Kubernetes. Handles training, serving, and pipeline orchestration.
Airflow: Workflow orchestration. Not ML-specific but excellent for building ML pipelines as directed acyclic graphs. Tons of operators available.
DVC: Data version control. Tracks data files using Git-like semantics. Integrates with Git workflows. Essential if you're serious about data versioning.
Weights & Biases: Experiment tracking, dataset versioning, model registry. Polished product, good for teams that want managed infrastructure.
Neptune: Similar to W&B. Experiment tracking, model registry, collaboration features.
SageMaker, Vertex AI, Azure ML: Cloud-native MLOps platforms. Trade control and flexibility for convenience. Good if you're on that cloud already.
Governance and Compliance
As your ML systems get more critical, governance becomes essential. Questions you need to answer: Who can deploy models? What testing is required? How do we audit what happened? How do we ensure fairness and catch bias?
Set up a model registry where models go through approval workflows. Require documentation: what data was used? How was it validated? What are known limitations? Log everything, who deployed what, when, with what approval.
For high-stakes models (credit decisions, healthcare, hiring), add extra gates: independent validation, fairness audits, explainability requirements.
What to Do Monday Morning
- Audit your current ML systems: How are models currently trained? How often are they retrained? What's versioned? What's not?
- Identify the biggest gap: Is it data versioning? Is it monitoring? Is it automated retraining? Pick one gap and focus there.
- Set up basic experiment tracking: Use MLflow or similar to start logging experiments. Version your data and models.
- Add production monitoring: What metrics matter for your model? Set up dashboards and alerts for at least accuracy, latency, and data drift.
- Build a retraining trigger: Set a schedule (weekly, monthly, or data-drift-based) to automatically retrain on fresh data and deploy if the new model is better.
- Document the process: Create a runbook for what happens when monitoring detects a problem. Make MLOps explicit and shared across your team.
Case Study: Ride-Sharing Dispatch at Scale
Let's walk through a real-world MLOps scenario that shows why these practices matter. A ride-sharing platform with 2M daily active riders needs to optimize dispatcher efficiency. Their current system uses rule-based logic: match drivers to riders based on proximity and driver acceptance history.
The Problem: Driver earnings are stagnant, rider wait times are increasing, and matching efficiency (acceptance rate) has plateaued at 62%. The product manager hypothesizes that a machine learning model trained on historical matching patterns could improve this. They want to increase acceptance rates to 75% within Q2.
Week 1-2: Data and Experiment Setup
The ML engineer audits training data: 6 months of historical ride requests (12M rides), driver acceptance/rejection signals, and outcome data (ride completed, cancelled, rating). They version the dataset using DVC and document: which time periods, which geographies, any data quality issues. A known issue: data from early COVID had anomalous patterns. They exclude it.
They build a baseline model using XGBoost, trained on: driver distance, driver acceptance rate, time of day, pickup location, destination area, weather, driver vehicle type. The model predicts acceptance probability for each (driver, request) pair. Validation accuracy: 91%.
Week 3: Canary Deployment (5% Traffic)
The baseline model is deployed to 5% of ride requests using a feature flag. The dispatch system continues using rule-based logic for 95% of traffic, ML model for 5%. Metrics tracked: acceptance rate, completion rate, driver earnings, rider satisfaction, inference latency.
Result: 5% traffic shows 68% acceptance rate (vs 62% baseline). Small improvement, but statistically significant. Latency: 47ms (within budget). They expand to 10% traffic.
Week 4: Scaling to 25%
Now the model serves 25% of traffic. Two problems emerge: (1) inference latency creeps to 110ms during peak hours (unacceptable, dispatch can't wait). (2) Acceptance rate improvement plateaus at 68% (not approaching the 75% target).
The team realizes the latency issue: their model makes predictions at dispatch request time, but dispatch service is bottlenecked. Solution: pre-compute driver acceptability scores every 30 seconds for all idle drivers, then lookup (near-instant) instead of realtime prediction. Redesign takes 3 days. Latency drops to
- Baseline acceptance rate: 62%
- Optimized rate: 71% (+14% improvement)
- Driver earnings increase: +$8/day per active driver (~$16M annualized for their 2M daily drivers)
- Rider wait time: -5 minutes (30 to 25 minutes)
- Infrastructure cost: +2% (worth the revenue impact)
- Time to 71% acceptance: 8 weeks (includes iteration, not a straight line)
- Ongoing maintenance: 1 ML engineer part-time monitoring and retraining
What Made This Work:**
They invested in infrastructure upfront (feature flags for testing, monitoring systems). They iterated fast (weekly deployments, quick feedback). They understood the business (realized the 75% target was unrealistic given constraints). They monitored in production (caught data drift and reacted). They automated retraining (didn't need constant manual intervention).
When MLOps Fails: Common Scenarios
Failure 1: Deploying Without Monitoring
A team builds a churn prediction model. Accuracy on test data: 89%. They deploy to production. Three weeks later, business team notices churn is going up (opposite of what they expected). The model is degrading silently, new user cohorts have different churn patterns, and the model wasn't trained on them. Without monitoring, they didn't see it until business metrics showed the problem. Cost: two weeks of increased churn affecting revenue, plus emergency retraining.
How MLOps would have prevented this: Set up monitoring for prediction accuracy per user cohort. Have automated alerts if accuracy drops below threshold. Catch the problem in days, not weeks.
Failure 2: Training-Serving Skew
A team builds a feature preprocessing pipeline for training. During training, they normalize input features (subtract mean, divide by std). During serving, they... forget to include the same normalization. The model receives un-normalized input. Predictions are garbage. The model crashes into production.
The fix is manual and painful: revert the model, implement the normalization in the serving pipeline, retrain, redeploy. Two days of downtime.
How MLOps prevents this: Version your feature engineering code. Apply the exact same code during training and serving. Use a feature store that enforces this consistency. Unit test that preprocessing is identical in both paths.
Failure 3: Silent Model Degradation
A recommendation model is trained on user behavior from 2025. Deployed in January 2026. It performs okay but worse than the rule-based system. The team doesn't realize it's degrading. They're focused on other work. By March, the model is 5% worse than the baseline. Customer complaints increase. Eventually, they pull the model. Investigation shows: user behavior shifted in January (new product features changed how users browse). The model was trained on old behavior patterns and couldn't adapt.
How MLOps prevents this: Continuously monitor model performance vs baseline. Have alerts if the model underperforms. Have automatic rollback triggered by alerts. Never let a bad model run silently.
Failure 4: Data Poisoning Feedback Loop
A fraud detection model is deployed. It flags suspicious transactions for manual review. A bad actor figures out the model's logic (through trial and error) and crafts transactions that evade it. These evasions become training data for the next model iteration. The next model learns the attacker's patterns and becomes weaker.
How MLOps helps: Audit training data for contamination. Track where labeled data comes from. Monitor for unusual attack patterns. Have human review as a gate (don't auto-accept model predictions without validation for security-critical use cases).
Failure 5: Organizational Handoff Failure
The ML team builds a model. It works. Then the ML engineer leaves. No documentation. No code comments. No runbooks. The model still runs, but nobody on the team understands how to maintain it. When it degrades, there's no playbook for what to do. They have to reverse-engineer the model from scratch.
How MLOps helps: Document everything (why this model, what data, what assumptions). Version the model and make it reproducible. Document the monitoring and alerts. Document the retraining process. Treat the model like you treat any production system: it needs documentation and runbooks.
FAQ
Q: Do we need MLOps if we're using third-party models through APIs?
A: Yes, but simpler. You're not retraining, but you still need to monitor: is the API working? Is latency acceptable? Are predictions reasonable? Are you handling API failures gracefully? You need less infrastructure but still need monitoring and fallback logic.
Q: How often should we retrain?
A: Depends entirely on data drift. Fast-changing domains (fraud detection, stock prices) might need daily or hourly retraining. Stable domains (technical documentation classification) might be fine with quarterly. Monitor data drift and trigger retraining when it exceeds thresholds.
Q: Can we use cloud services instead of building MLOps infrastructure?
A: Absolutely. AWS SageMaker, Google Vertex AI, and Azure ML all provide end-to-end MLOps. You trade some flexibility for convenience. They handle versioning, monitoring, and deployment for you. Good choice if you're on that cloud and don't need custom infrastructure.
Q: What's the cost of poor MLOps?
A: Models degrading silently in production. Bad predictions affecting customers. Manual firefighting when something breaks. Emergency retraining at 2am. Loss of trust in ML systems. The cost compounds over time as technical debt builds.
Q: How do we know if a model is truly degrading or if it's just variance?
A: Track confidence intervals around your metrics. If your accuracy was 94% +/- 1% before, and it drops to 92%, that might be variance. If it drops to 87%, something is wrong. Use statistical tests to distinguish signal from noise. And always look at what changed: new data distribution? New behavior? New attack pattern? Understanding why helps you respond.
MLOps is the infrastructure that keeps ML models working in production. Version everything (code, data, models, configurations). Automate the pipeline from raw data to deployed model. Monitor continuously for data drift and model degradation. Retrain automatically when needed. Without these practices, your models will fail silently and you won't know until customers are affected. With them, you have a sustainable, maintainable ML system.
On This Page
Watch the Lecture
Why ML Systems Are Different
The MLOps Pipeline
Implementing MLOps
Tools and Platforms
Governance and Compliance
Case Study: Ride-Sharing Dispatch
When MLOps Fails
Monday Morning Action
FAQ
Chapter Details
Part ofChapter 5
Skill.re