30.1 Comparison Table
| Strategy | Traffic Shift | Rollback Speed | Infra Cost | Best For |
|---|---|---|---|---|
| Rolling Update | Gradual, pod-by-pod, single environment | Slow (re-roll previous version pod-by-pod) | Low (no duplicate env) | Default choice for low-risk, backward-compatible changes |
| Blue-Green | Instant cutover between two full environments | Instant (flip back to blue) | High (2x infra during cutover window) | High-risk releases needing instant, guaranteed rollback |
| Canary | Gradual % of traffic to new version, expand on success | Fast (route 100% back to stable) | Low-moderate | Validating a risky change against real traffic before full rollout |
| A/B Testing | Traffic split by user segment/feature flag, not just version | N/A (feature-flag toggle) | Low | Testing business/product hypotheses, not just technical safety |
| Shadow (Dark Launch) | New version receives a mirrored copy of live traffic, response discarded | N/A (no user impact — shadow never serves) | Moderate (duplicate compute for shadow) | Validating a new model/service’s behavior against production traffic with zero user risk |
30.2 Rolling Update
apiVersion: apps/v1
kind: Deployment
metadata: { name: inference-api }
spec:
replicas: 6
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1 # at most 1 extra pod above desired count during rollout
maxUnavailable: 1 # at most 1 pod unavailable during rollout
template:
spec:
containers:
- name: inference-api
image: myregistry/inference-api:v2.2
30.3 Blue-Green
# Two full Deployments, Service selector flips between them
apiVersion: apps/v1
kind: Deployment
metadata: { name: inference-api-blue, labels: { version: blue } }
spec:
replicas: 6
selector: { matchLabels: { app: inference-api, version: blue } }
template:
metadata: { labels: { app: inference-api, version: blue } }
spec: { containers: [{ name: inference-api, image: "myregistry/inference-api:v2.1" }] }
---
apiVersion: apps/v1
kind: Deployment
metadata: { name: inference-api-green, labels: { version: green } }
spec:
replicas: 6
selector: { matchLabels: { app: inference-api, version: green } }
template:
metadata: { labels: { app: inference-api, version: green } }
spec: { containers: [{ name: inference-api, image: "myregistry/inference-api:v2.2" }] }
---
# Cutover: flip this selector from `version: blue` to `version: green`
apiVersion: v1
kind: Service
metadata: { name: inference-api-svc }
spec:
selector: { app: inference-api, version: blue } # ← change to green to cut over
ports: [{ port: 80, targetPort: 8080 }]
30.4 Canary (with a service mesh / Argo Rollouts)
# Argo Rollouts canary strategy example
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata: { name: inference-api }
spec:
replicas: 10
strategy:
canary:
steps:
- setWeight: 10 # 10% of traffic to new version
- pause: { duration: 10m }
- setWeight: 25
- pause: { duration: 10m }
- setWeight: 50
- pause: { duration: 10m }
- setWeight: 100
analysis:
templates:
- templateName: error-rate-check
startingStep: 1
template:
spec:
containers:
- name: inference-api
image: myregistry/inference-api:v2.2
Automated canary analysis: pair each setWeight step with an AnalysisTemplate that queries Prometheus for error rate / latency P99 on the canary pods specifically — if the canary breaches a threshold, Argo Rollouts auto-aborts and rolls back without human intervention.
30.5 A/B Testing
Distinct from canary in intent: canary tests technical safety of a new deployment; A/B tests a product/business hypothesis by routing defined user segments to different variants, often for a sustained period, using a feature-flag system (LaunchDarkly, Azure App Configuration feature flags, or a custom header-based router) rather than a progressive rollout schedule.
# Ingress-level A/B split using header-based routing (NGINX Ingress example)
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: inference-api-variant-b
annotations:
nginx.ingress.kubernetes.io/canary: "true"
nginx.ingress.kubernetes.io/canary-by-header: "X-Experiment-Group"
nginx.ingress.kubernetes.io/canary-by-header-value: "variant-b"
spec:
rules:
- host: api.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service: { name: inference-api-variant-b-svc, port: { number: 80 } }
30.6 Shadow Deployment
Live Traffic ──► Router ──► Production Service (v1) ──► Response to user
│
└─────► Shadow Service (v2) ──► Response DISCARDED (logged for comparison only)
# Istio VirtualService — traffic mirroring for shadow deployment
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata: { name: inference-api }
spec:
hosts: ["inference-api"]
http:
- route:
- destination: { host: inference-api-v1, subset: v1 }
weight: 100
mirror:
host: inference-api-v2 # v2 gets a mirrored copy of every request
subset: v2
mirrorPercentage:
value: 100.0 # mirror 100% of traffic for full comparison
Why shadow matters specifically for AI/ML releases: it’s the only strategy that lets you compare a new model’s real-world output against the current model on live, unmodified production traffic with zero risk to users, since the shadow’s response is never actually served — ideal for validating a retrained model or a new prompt version before it ever influences a real user-facing decision.
30.7 Interview Q&A
Q1: You’re rolling out a new fine-tuned model to replace the current production model. Which deployment strategy do you choose and why?
A: I’d use a combination: shadow deployment first, then canary. Shadow lets me run the new model against real production traffic and log both models’ outputs side by side — comparing quality, latency, and edge-case behavior — with zero user-facing risk, since the shadow’s responses are discarded. Once shadow metrics look good over a representative time window, I move to canary: route a small percentage of real traffic (say 10%) to the new model, with automated analysis on error rate and any quality-proxy metrics I can compute online, gradually increasing the weight while watching for regressions. I’d avoid a straight blue-green cutover for a model change specifically because model quality regressions are often subtle (not a 500 error, but a worse answer) — canary’s gradual exposure with real user feedback loops catches that better than an instant full cutover would.
Q2: What’s the difference between canary and A/B testing, and why do teams conflate them?
A: Canary is a deployment safety technique — it answers “is this new version technically safe to run in production,” using traffic-weight ramps and automated rollback on error-rate/latency regressions, typically over a short window before reaching 100%. A/B testing is a product experimentation technique — it answers “which variant produces better business outcomes,” using consistent, often long-lived user-segment assignment (so the same user always sees the same variant, which canary explicitly doesn’t guarantee) and statistical significance testing on business metrics, not infra health metrics. Teams conflate them because both involve “some users see the new thing, some don’t,” but the tooling, duration, and success criteria are different — I’d implement canary via a progressive-delivery tool (Argo Rollouts/Flagger) tied to infra metrics, and A/B via a feature-flag system tied to a proper experimentation/analytics platform.
Q3: When would you choose blue-green over rolling update despite the extra infrastructure cost?
A: When the risk of a partial-rollout state is worse than the cost of running two full environments — e.g., a change involves a breaking database schema migration, a major dependency upgrade, or a regulatory/compliance-sensitive release where I need to guarantee that either 100% of traffic is on the old version or 100% is on the new version, with an instant, single-action rollback (flip the Service selector or swap the load balancer target) rather than a multi-minute rolling rollback. Rolling update is my default because it’s cheaper and works for the vast majority of backward-compatible changes; I reserve blue-green for the specific subset of releases where “no mixed-version state, ever” is a hard requirement.