C.W.K.
Stream
Lesson 01 of 13 · published

Deployment Strategies

~13 min · strategies, rollout, rollback

Level 0Apprentice
0 XP0/101 lessons0/10 achievements
0/120 XP to next level120 XP to go0% complete

How traffic moves from old to new

Pick a deployment strategy based on how risky the change is and how fast you can detect failure. Three classic shapes:

Recreate (downtime deploy)

  • Stop old, start new. Brief downtime.
  • Easiest to reason about. Default for personal projects, low-traffic services.
  • Bad for: anything with users.

Rolling

  • Replace instances N at a time. Old + new run side by side mid-deploy.
  • Default for Kubernetes deployments, ECS rolling, etc.
  • Watch for: schema changes that break old instances reading new schema (or vice versa).

Blue/Green

  • Two full copies of prod (blue + green). Deploy to inactive, run smoke, flip traffic, decommission old.
  • Instant rollback by flipping the load balancer back.
  • Costs: 2× infrastructure during deploy.

Canary

  • Deploy to 1 → 5 → 25 → 100% of traffic over time.
  • Monitor error rate / latency at each step. Auto-roll back if it spikes.
  • The gold standard. Requires good observability and a feature-flag or weighted-router.

The pipeline shape mirrors the strategy

A canary pipeline has more jobs (one per traffic step) than a rolling one (one big deploy). The strategy you pick determines the YAML shape and how complicated rollback is.

Code

Canary deploy with three traffic steps·yaml
jobs:
  deploy-canary-5:
    runs-on: ubuntu-latest
    environment: production
    steps:
      - run: ./deploy.sh --weight 5
      - run: ./check-health.sh --duration 5m

  deploy-canary-25:
    needs: deploy-canary-5
    runs-on: ubuntu-latest
    environment: production
    steps:
      - run: ./deploy.sh --weight 25
      - run: ./check-health.sh --duration 10m

  deploy-full:
    needs: deploy-canary-25
    runs-on: ubuntu-latest
    environment: production
    steps:
      - run: ./deploy.sh --weight 100

  rollback-on-fail:
    needs: [deploy-canary-5, deploy-canary-25, deploy-full]
    if: failure()
    runs-on: ubuntu-latest
    steps:
      - run: ./rollback.sh

External links

Exercise

Document your current deploy strategy in one paragraph. Include MTTR (when have you rolled back; how long did it take?) and the strategy's tradeoffs. Decide whether to stay or upgrade.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.