Compare Zero-Downtime Deployment Strategies: Blue-Green vs Canary vs Rolling Updates.
❓ Interview Prompt: Compare Blue-Green Deployments (instant router cutover), Canary Deployments (percentage-based traffic splitting), and Rolling Updates (instance-by-instance replacement).
Evaluating zero-downtime deployment strategies:
| Strategy | Mechanism | Rollback Speed | Resource Cost |
|---|---|---|---|
| Rolling Update | Replaces old container instances with new ones step-by-step | Slower (requires rolling back instances) | Low ($100\%$ capacity) |
| Blue-Green | Maintains 2 identical environments; router switches $100\%$ traffic | Instant (switch router back to Blue) | High ($200\%$ capacity during deploy) |
| Canary | Routes small traffic percentage ($1\% \rightarrow 10\% \rightarrow 100\%$) to new version | Instant (route $100\%$ back to stable version) | Low to Moderate |
Code Implementation Example
# Kubernetes Deployment RollingUpdate Strategy Config
spec:
replicas: 10
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 2 # Create 2 extra new pods during deploy
maxUnavailable: 0 # Zero pods offline during deploy!Choose Blue-Green for instant full cutovers, Canary for high-risk releases, and Rolling Updates for cost-effective capacity usage.