Introduction
Deploying microservices to production is the riskiest time. Deployment strategy decides blast radius when there is a bug — affects 100% of users or only 5%? This article compares strategies and provides guidance on choosing the right one.

1. Rolling Update
Kubernetes mặc định:
Pod v1 ●●●●● (5 replicas)
Deploy v2:
Step 1: ●●●●● + ○ (1 new pod v2 starting)
Step 2: ●●●● + ○○ (2 v2 ready, 1 v1 terminated)
Step 3: ●●● + ○○○ (3 v2 ready)
Step 4: ●● + ○○○○
Step 5: ○○○○○ (all v2)
● = v1, ○ = v2
Advantages: Zero downtime, gradual, K8s native Disadvantages: Mixed versions during rollout, rollback slow Use case: Low-risk changes, stateless services
2. Blue/Green Deployment
Blue (current, live): ●●●●● ← traffic
Green (new, staging): ○○○○○ ← no traffic
Test Green thoroughly, then switch:
Blue: ●●●●● ← no traffic (standby)
Green: ○○○○○ ← ALL traffic switched instantly
Advantages: Instant rollback (switch back to blue), full testing before live Disadvantages: 2x resources needed, database migration must be backward compatible Use case: Critical services, when instant rollback is needed
3. Canary Deployment ⭐
Step 1: ●●●●● (100% v1)
Step 2: ●●●●○ (90% v1, 10% v2) ← canary
Step 3: Monitor metrics (error rate, latency, CPU)
Step 4a: Metrics OK → ●●●○○ → ●●○○○ → ○○○○○ (promote)
Step 4b: Metrics BAD → ●●●●● (rollback, remove canary)
Advantages: Smallest blast radius, data-driven promotion Disadvantages: Complex setup, needs good monitoring Use case: Most production deployments — recommended default
4. Argo Rollouts (Progressive Delivery)
# rollout.yaml
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: product-service
spec:
replicas: 5
strategy:
canary:
canaryService: product-service-canary
stableService: product-service-stable
steps:
- setWeight: 5
- pause: { duration: 5m }
- setWeight: 20
- pause: { duration: 10m }
- setWeight: 50
- pause: { duration: 15m }
- setWeight: 100
analysis:
templates:
- templateName: success-rate
startingStep: 2
args:
- name: service-name
value: product-service
---
apiVersion: argoproj.io/v1alpha1
kind: AnalysisTemplate
metadata:
name: success-rate
spec:
metrics:
- name: success-rate
interval: 1m
successCondition: result[0] >= 0.99
provider:
prometheus:
address: http://prometheus:9090
query: |
sum(rate(http_requests_total{service="{{args.service-name}}",code=~"2.."}[5m]))
/
sum(rate(http_requests_total{service="{{args.service-name}}"}[5m]))
5. Feature Flags
Deploy code to production without enabling for users:
// Feature flag check
const unleash = require('unleash-client');
app.get('/api/products', (req, res) => {
const products = getProducts();
if (unleash.isEnabled('new-recommendation-engine', {
userId: req.user.id
})) {
// New feature, enabled for specific users
products.forEach(p => {
p.recommendations = newEngine.getRecommendations(p.id);
});
}
res.json(products);
});
Feature Flags + Canary
1. Deploy v2 with feature flag OFF → 100% users get old behavior
2. Enable flag for 5% users → monitor
3. Gradually increase → 20% → 50% → 100%
4. Remove flag from code after full rollout
6. Decision Matrix
| Strategy | Risk | Speed | Cost | Rollback | Best For |
|---|---|---|---|---|---|
| Rolling | Medium | Slow | Low | Slow | Low-risk changes |
| Blue/Green | Low | Fast | High (2x) | Instant | Critical services |
| Canary | Very Low | Medium | Low | Fast | Default choice |
| Feature Flags | Very Low | Instant | Low | Instant | UX changes |
Recommended
E-Commerce Platform:
├── Backend services: Canary (Argo Rollouts) + Auto analysis
├── Micro Frontends: Canary via CDN traffic splitting
├── Database changes: Blue/Green (backward compatible)
└── UI features: Feature flags (Unleash)
7. Rollback Strategy
| Components | Rollback Method |
|---|---|
| K8s Deployment | kubectl rollout undo |
| Argo Rollout | Auto-rollback on failed analysis |
| MFE on CDN | Point to previous version |
| Database | Forward migration (never rollback schema) |
| Feature Flag | Disable flag instantly |
Summary
- Rolling Update: K8s default, simple, good for low-risk
- Blue/Green: instant rollback, 2x cost
- Canary: smallest blast radius — recommended default
- Argo Rollouts: automated progressive delivery with analysis
- Feature Flags: deploy ≠ release, instant enable/disable
Next article: Lesson 26: Full-Stack Observability — Logs, Metrics & Traces