Model Serving and Deployment
A model in a notebook is a prototype. A model that handles 10,000 requests per second — and rolls back instantly when something goes wrong — is a product.
A model in a notebook is a prototype. A model that handles 10,000 requests per second — and rolls back instantly when something goes wrong — is a product.
From trained artifact to production system handling real traffic safely.
Once a model passes offline evaluation, it must serve predictions to real users. There are three fundamental serving patterns, each with different latency, throughput, and infrastructure requirements:
The gap between “works on my machine” and “works in production” is closed by packaging the model with its complete runtime in a Docker container. A containerised model image contains:
The container is the deployment unit. Any environment that runs Docker — Kubernetes, ECS, Cloud Run, a VM — runs the model identically.
A canary deployment routes a small percentage of production traffic (typically 1–10%) to a new model version while the stable version handles the rest. If the canary performs well on live traffic (latency, error rate, business metrics), traffic shifts incrementally: 10% → 25% → 50% → 100%. If it degrades, rollback is instant: redirect all traffic back to the stable version.
Canary deployments decouple model release from model exposure: a new version can be deployed to infrastructure before any real traffic touches it. The slider in the visualisation above illustrates this traffic split.
In shadow mode, the new model runs in parallel with the production model on all live requests. Both receive the same inputs, but only the production model's outputs are returned to users. The new model's predictions are logged silently for comparison.
Shadow mode answers: “Would the new model have made different decisions on real traffic?” It catches edge cases invisible in offline evaluation without any user-facing risk. The cost: double the compute for the shadow period.
Canary and A/B testing both split traffic, but serve different purposes:
Online serving requires sub-100ms feature retrieval. A feature store provides:
Every production deployment needs a rollback path. The standard patterns:
Say the answer out loud before you reveal it.
What are the three ML serving patterns and when do you use each?
What is the difference between a canary deployment and A/B testing?
What does shadow mode accomplish that canary deployment cannot?
What problem does a feature store solve?
Online serving <100ms, batch overnight, streaming event-triggered. Canary = safety (limit blast radius). Shadow mode = zero user risk. Feature store = same code offline and online. Blue-green = instant rollback.