Q&A-1Choose a deployment strategy for a critical service.
Answer
Assumptions I'd state up front: Kubernetes, ~200 pods, 1,000 rps peak, p99 40 ms, SLO 99.95% availability, and the service owns its own schema. The hard part of deploying a critical service isn't the pod swap: it's that a bad release shows up in the tail, and that rollback must still work after the new version has written data.
The answer: canary with automated metric analysis (Argo Rollouts or Flagger driving Istio/Envoy traffic weights), feature flags for capability exposure, and expand/contract migrations so every step is reversible. Blue-green only when I must validate a whole environment before any user sees it and can afford 2× capacity. Rolling only for low-risk, schema-compatible changes.
Why canary, mechanically
A canary bounds blast radius and gates promotion on evidence. Rolling gives you neither: every pod is eventually replaced, and nothing stops the rollout when error rate climbs. You find out from the SLO burn. Blue-green gives you a fast switch (seconds, a weight flip) but exposes 100% of traffic at once, and both versions run against one database during the switch, so any non-additive schema change is a live hazard.
| extra capacity | exposure | evidence gate | rollback | state risk | |
|---|---|---|---|---|---|
| rolling | ~25% surge | all users, gradually | none | re-roll, minutes | schema must be compatible |
| blue-green | 100% | all at switch | pre-switch smoke | flip, seconds | two versions, one DB |
| canary | 1–5% | bounded cohort | automated metrics | setWeight 0, seconds | same as rolling |
The rollout
apiVersion: argoproj.io/v1alpha1
kind: Rollout
spec:
strategy:
canary:
canaryService: svc-canary
stableService: svc-stable
trafficRouting:
istio:
virtualService: {name: svc-vs}
analysis:
templates: [{templateName: success-rate}]
startingStep: 1
steps:
- setWeight: 1
- pause: {duration: 10m}
- setWeight: 5
- pause: {duration: 10m}
- setWeight: 25
- pause: {duration: 15m}
- setWeight: 50
- pause: {duration: 15m}
- setWeight: 100The AnalysisTemplate queries Prometheus every minute and aborts after failureLimit: 2 consecutive failures:
metrics:
- name: success-rate
interval: 1m
successCondition: result[0] >= 0.995
failureLimit: 2
provider:
prometheus:
address: http://prometheus.monitoring:9090
query: |
sum(rate(http_requests_total{service="{{args.service-name}}",code!~"5.."}[2m]))
/ sum(rate(http_requests_total{service="{{args.service-name}}"}[2m]))Why 1% first, then 5%: at 1,000 rps, 1% is 10 rps. Ten minutes gives 6,000 requests, so p99 rests on ~60 tail samples: enough to catch a hard 5xx spike, too noisy for a latency regression. 5% (50 rps) over ten minutes gives 30,000 requests and ~300 tail samples, which is where the p99 gate becomes trustworthy. That's the arithmetic that sets the step sizes, not taste.
Failure modes and how I'd catch them
- Canary passes, 100% breaks. Usually cohort skew: header-routed canary gets internal traffic only. Detect by asserting canary request rate > 0 and comparing canary vs. stable on the same metric before each promotion.
- gRPC/long-lived connections pin to stable pods, so the canary sees no traffic and the analysis passes vacuously. Detect: alert if canary rps is below the expected weight × total.
- A migration poisons stable too. Run migrations as a pre-sync step, additive only (add column, backfill, dual-write, then drop in a later release). Detect: schema-diff check in CI against the previous release.
- Rollback isn't instant. Pods drain for 30–60 s; watch 5xx during termination, and keep the previous ReplicaSet warm so
setWeight: 0is a traffic flip, not a reschedule. - Retries mask errors. A 0.5% error rate can hide behind client retries; gate on server-side 5xx and client-observed latency, not just success rate.
Feature flags sit on top: they decouple capability exposure from code deployment, so a canary that passes can still ship dark and be enabled per-tenant later.
Curated: · Written: · Reviewed:
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.