MLOpsModel Deployment & CI/CD Automation

How do you design safe production model rollouts and rollback strategies?

A safe production model rollout moves an already-tested, immutable inference release into real traffic in controlled stages, measures user-visible and ML-specific health at each stage, and restores the last known-good serving release when a predeclared safety gate fails. “Deployed” does not mean “fully promoted”: rollout completion requires observed evidence, adequate sample sizes, clear ownership, and a reversible change.

Curriculum boundary: Question 120 created the immutable model+runtime+feature-contract release; Question 121 validated that exact release in staging. Question 122 begins *production exposure and recovery*. Question 89 handled rolling back a registry alias, which is not the same as rerouting production inference traffic or restoring compatible application and feature versions. Question 119 compared operating modes; this lesson focuses on release orchestration of online endpoints, with targeted notes for batch and streaming.

Beginner-friendly production incident

A delivery service operates a delay-risk predictor. Production revision risk-r27 is stable; candidate risk-r28 passed staging. The new release is more accurate on historical tests but its feature lookup performs poorly for a small set of cities. If all requests move to r28 immediately, customers in those cities experience slow checkout. A 5% canary with per-release and per-city metrics can expose the regression while most traffic remains on r27.

The release controller should know:

  • Stable identity: pinned image/model/feature contract/config for r27, with healthy capacity retained.
  • Candidate identity: pinned tested release r28; never reload a mutable registry alias independently on different replicas.
  • Traffic policy: which requests can go to each version, by weight and optionally by cohort.
  • Promotion evidence: baseline and candidate error, timeout, latency, feature health, and decision-related ML signals, with sample-size/window rules.
  • Recovery action: immediately stop increasing candidate exposure, route away from r28 when safe, verify the old release remains healthy, and record the incident.

Three rollout strategies

1. Rolling update: replace serving replicas in controlled batches

  • The orchestrator gradually starts new replicas and removes old ones as readiness permits. In Kubernetes, maxSurge caps extra Pods above desired capacity, and maxUnavailable caps unavailable Pods during the update.
  • Illustration: with 10 desired replicas, maxSurge: 2 and maxUnavailable: 1, the controller can run up to 12 Pods and may allow as few as 9 available during the transition, subject to its scheduling/readiness behavior.
  • Best for: compatible, low-risk updates when sophisticated traffic splitting is not required and replicas have reasonable warmup.
  • Trade-off: the fraction of new Pods is not an exact fraction of requests; heterogeneous capacity, sticky sessions, gateway routing and warmup skew traffic. Native Kubernetes rolling updates do not inherently apply ML-aware analysis or an automated metric-driven rollback. Add a delivery controller/guardrails when these are required.
  • Failure mode: a readiness probe reports success before the large model is warmed; ingress sends real requests and p99 spikes. Keep warmup and readiness meaningful, and reserve capacity during the transition.

2. Blue-green: retain two independently deployable fleets

  • Keep blue (current release) handling production traffic while green (new release) starts and passes production-side pre-promotion checks. Switch routing deliberately, often in one step; monitor a post-switch bake period. Blue should remain intact until rollback risk is acceptable.
  • Best for: high-impact revisions, easy full-fleet reversal, or when side-by-side infrastructure is feasible.
  • Trade-off: temporarily paying for two fleets; old and new releases must remain compatible with shared feature services, caches, schemas and business side effects.
  • Failure mode: blue is deleted immediately after the switch; a subtle degradation becomes visible minutes later, and rollback now requires cold-starting the old fleet. Retain warm capacity for the agreed observation window. Rolling back traffic does not undo external notifications, database migrations or already-sent decisions.

3. Canary / progressive delivery: control real request exposure

  • Route a small specified share of eligible requests to the candidate (for example 1% → 5% → 25% → 50% → 100%) with observation at each step. Advance only if both technical SLOs and guardrail metrics pass; otherwise pause or abort.
  • Best for: high-volume online predictions with rapid error/latency feedback and reliable routing and per-version telemetry.
  • Trade-off: requires metric-aware delivery automation, traffic routing, enough sample volume and careful interpretation. A 1% canary may be underpowered for rare harms, segments or delayed outcome labels.
  • Failure mode: canary aggregate p95 looks fine while one high-risk geography regresses. Break down by important cohorts and add hard checks on feature availability, severe prediction anomalies and business safety signals.

Argo Rollouts supplies advanced canary/blue-green controllers, metric analysis and integration with routers; SageMaker AI has managed blue/green/rolling guardrails and monitored rollback for supported real-time and asynchronous endpoints. Cloud/provider feature support must be checked before selecting a strategy. These are product capabilities, not guarantees that arbitrary model-quality regressions are automatically detected.

Numerical example: traffic allocation and blast radius

Assume a checkout predictor serves 400 requests/second and a 5% canary is enabled.

  • Candidate request rate: 400 × 0.05 = 20 RPS.
  • Stable request rate: 400 × 0.95 = 380 RPS.
  • Over a 10-minute analysis window, total requests are 400 × 600 = 240,000; the expected candidate share is 20 × 600 = 12,000; the stable share is 228,000.
  • Suppose the stable version yields 0.2% 5xx (228000 × .002 = 456), while the canary yields 1.5% (12000 × .015 = 180). The candidate has 7.5× the observed error rate.
  • If the policy requires candidate 5xx ≤ 0.5% and no more than 2× a comparable baseline, the candidate fails both: 1.5% exceeds 0.5%, and 7.5× exceeds 2×.
  • Decision: ABORT the promotion; restore candidate routing to 0%; verify the old fleet's capacity and normal error rate. Do not describe “all traffic is safe” until request draining, caches and in-flight work have been checked.

This is an illustrative deterministic allocation. Actual weighted-routing results fluctuate; analyze observed denominators, confidence intervals and representative mix. A globally low error percentage can still mask concentrated harms.

Numerical example: why canary sample size matters

Suppose true error rate is 0.1%. In a candidate sample of 200 independent requests, expected errors are 200 × 0.001 = 0.2, and the probability of observing zero errors is approximately (1-0.001)^200 ≈ 81.9%.

A canary with zero observed failures among 200 requests is therefore not proof of safety for a rare failure mode. A helpful zero-event rule of thumb is that the approximate 95% upper bound is 3/n: with 200 samples it is about 1.5%, far above the target 0.1%. Cohorts, autocorrelation and burst patterns make naive independent-binomial assumptions optimistic. Establish minimum volume, bake time and uncertainty rules before deployment.

Practical rollout procedure: stage, measure, decide

  1. Authorize an exact release. Consume the staging gate from Question 121, check approved immutable model/image digests, feature contract, access and rollback target. Require no unresolved critical failures.
  2. Verify capacity and dependency compatibility. Old and candidate fleets must handle their routed traffic; check GPU memory, cold-start time, queues, feature-store quotas and fallback. Confirm requests can reach either version without breaking schema or downstream side effects.
  3. Choose routing mode. Use weighted routing at gateway/mesh/provider if exact weights matter. For sticky sessions or entity-based decisions, use stable entity hashing so repeated requests do not alternate unpredictably; assess cohort bias.
  4. Start with low exposure. Warm the candidate, run production-side smoke checks, then route a safe small slice. Where appropriate, use a shadow path for side-effect-free evaluation before exposing candidate decisions; avoid duplicate external actions.
  5. Compare candidate with a contemporaneous baseline. Label telemetry by release, route, region, tenant/cohort, feature version and input/request class. Check p95/p99, error/timeout rate, saturation, prediction distribution, severe-score shifts and feature staleness.
  6. Observe during a defined bake window. Only advance when sufficient samples, time coverage and all blocking gates pass. Delayed business outcomes may require a hold or later follow-up even after technical promotion.
  7. Escalate traffic progressively. Each step is a new decision. A global severe incident immediately aborts regardless of sample volume; normal statistical uncertainty pauses rather than granting automatic promotion.
  8. Finish promotion and retain rollback. Confirm 100% intended traffic reaches candidate, monitor post-promotion, record release IDs, model version mapping and approval evidence. Keep the old fleet/artifacts available for the agreed rollback window.
  9. Reconcile and learn. If aborted, preserve traces and metric snapshots, classify root cause, fix or revert, revalidate in staging as required, and only then retry with a new release identity when artifacts change.

Example automated policy (conceptual YAML, not a vendor-specific manifest)

YAML
candidate_release: risk-r28 stable_release: risk-r27 route: strategy: canary steps_percent: [1, 5, 25, 50, 100] analysis: each_step_min_minutes: 10 min_candidate_requests: 5000 candidate_5xx_rate_max_percent: 0.5 candidate_5xx_ratio_to_stable_max: 2.0 p95_latency_max_ms: 250 feature_freshness_violations_max: 0 severe_business_guardrail: block on_failure: abort_and_route_to_stable retain_old_release_minutes: 60

The policy is deliberately illustrative; implement its metrics and rollback in the selected controller and add the needed sampling, comparison and multi-window safeguards. At 400 RPS, a 1% slice supplies only 4 RPS, so 5,000 candidate requests take about 5000/4 = 1250 seconds ≈ 20.8 minutes in ideal uniform traffic; a ten-minute window alone would be insufficient. A pause is the correct outcome until volume and time criteria are met.

Rollback: the right thing to reverse

  • Traffic rollback: route new requests from candidate back to previously healthy stable instances; keep enough stable capacity, verify routing weights and drain in-flight requests appropriately.
  • Deployment rollback: restore the previous immutable image/model/configuration bundle and health probes. Do not assume that changing a registry alias updates already-running model processes.
  • Feature/schema rollback: verify compatibility between old model code and current feature service. Use backward-compatible schema transitions or an explicit migration/dual-read strategy.
  • State and side effects: an old model returning doesn't revoke predictions, messages or external decisions already made. Record versioned decisions and define compensation/reconciliation where needed.
  • Rollback of model quality: delayed outcome labels can make errors visible after a technical bake window. Maintain longer-term drift/performance monitoring and a reversible release history.

Automated rollback triggers: error/timeout spikes, hard p95/p99 breach, failing readiness, unhealthy capacity, invalid prediction schema, critical missing/stale features, and severe model-specific safety anomalies. For ambiguous low-volume signals, *pause* to collect evidence instead of blindly promoting or thrashing between releases.

Rollback recovery objective: define a time goal for detecting, routing back and verifying recovery. For example, if detection takes 2 minutes, controller action 30 seconds and verification 90 seconds, the modeled recovery time is 4 minutes; it is not a guarantee. Drill it under actual infrastructure constraints.

Operational runbook for a failed canary

  1. Stop promotion and freeze the candidate release identity.
  2. Capture per-version and per-segment traces, failure counts, request distributions, current weights, feature contracts and recent dependency changes.
  3. Move traffic off candidate, keep old capacity and validate load balancing plus request-draining behavior.
  4. Check stable p95/p99, errors, feature freshness and business guardrails until they recover for an agreed window.
  5. Reconcile affected external side effects, record estimated impacted requests and notify owners.
  6. Open a corrective change; rerun staging validation on the new candidate before retry.

Avoid conflating operational restoration with investigation completion: protect users first, then use retained evidence for a root-cause review.

Release metrics to watch

  • Availability: 5xx, 4xx contract mismatch, timeouts and downstream dependency failures by release.
  • Latency: request p50/p95/p99, feature fetch time, model compute time, queue time and cold starts.
  • Capacity: CPU/GPU memory, concurrency, load balancer routing ratio, autoscaler headroom, warm replicas and saturation.
  • Model correctness: prediction distribution, schema validation failures, missing features, freshness, drift and feature/model version alignment.
  • Business impact: adverse decision rates, reversals, conversion or fraud/delay metrics by comparable cohort, with attention to delayed labels and noisy A/B comparisons.
  • Rollout control: current step, configured versus observed weights, elapsed bake time, samples by cohort, failed gate reason, who approved/aborted, and preserved rollback target.

Instrumentation must reflect *actual* candidate requests, not just desired route weights. Compare equivalent cohorts and time windows rather than treating model-mix shifts as model regressions.

When the model is batch or streaming

  • Batch release: no HTTP request weights. Route a bounded shadow sample, partition, dataset or logical run to the new pinned release; validate complete output and consumer parity, then promote for a future logical window. Keep prior committed outputs available. Reverting the scheduler alias will not repair already-published wrong scores; replace them via a controlled new revision.
  • Streaming release: use event-key cohorts or a bounded side-effect-free shadow processor when feasible. Coordinate model transition with checkpoints/savepoints and state-schema compatibility. On rollback, reconcile replayed outputs and external duplicate effects; routing to an old processor is not sufficient if state migration is irreversible.
  • Async inference: distinguish submitted job assignment from individual request routing; do not switch an in-flight job's model halfway through its work. Preserve job IDs and output-version traceability.

These adaptations extend, rather than repeat, Questions 116–119.

Cost and engineering trade-offs

  • Rolling updates usually avoid provisioning a second complete fleet, but temporarily shrink or surge capacity and offer less explicit blast-radius control without an extra delivery layer.
  • Blue-green offers a clear switch and fast *potential* reversibility but requires parallel capacity; AWS notes that two fleets incur charges during overlap, including bake periods.
  • Canary spreads risk over time but incurs router/controller and observability complexity, prolonged dual-fleet costs and statistical pitfalls.
  • Shadow traffic helps inspect outputs without controlling real decisions, but nearly doubles inference/feature load for shadowed requests and must suppress external side effects.
  • Sticky routing helps consistency for repeated entities but can produce biased segments; choose stable bucketing and compare correctly.

Common production mistakes

  • Assuming Kubernetes rolling readiness implies automated ML-quality rollback.
  • Using latest model aliases or mutable image tags during production changes.
  • Scaling down the old fleet before the post-release observation window ends.
  • Calling a 5% Pod count an exact 5% user traffic canary.
  • Promoting after a tiny sample with zero errors, with no uncertainty check.
  • Ignoring slow feature dependencies, region/tenant cohorts and delayed ground truth.
  • Letting retries and dual-serving trigger duplicate payments or notifications.
  • Rolling back only model weights while leaving incompatible preprocessing/features.
  • Marking rollback successful before verifying stable traffic and user-visible recovery.
  • Running experiments without clear abort ownership, incident playbook or immutable evidence.

Takeaway: Production rollout is a bounded-risk experiment over a pinned release. Use rolling updates for simple compatible replacements, blue-green for isolated reversible fleet switches, and canaries for measurable progressive exposure. Make every promotion conditional on evidence, and treat rollback as verified restoration of the *whole compatible serving path*, not a change of model alias.

#safe production model rollout rollback#MLOps canary blue green rolling deployment#model serving traffic shifting promotion gates#canary deployment numerical example ML inference#automated model rollback SLO monitoring#mlops#model-deployment#canary#blue-green#rollback

Learning Sequence

MLOps Curriculum

88% Completed
Up NextMLOps

How do shadow deployments and traffic mirroring validate ML models without affecting production decisions?

Explore Related Questions

Deepen your understanding across related MLOps topics.

Machinoai Logo
Machinoai

Your edge in the AI era. Deep dives into machine learning concepts, paper explainers, verified industry jobs, and developer tools.

© 2026 Machinoai. All rights reserved.