Traffic-Shifting Deployment Strategies

~8 min read

Canary and linear deployments — gradually exposing a new version to real traffic instead of switching everyone at once.

For Lambda and ECS deployments specifically, CodeDeploy supports traffic-shifting strategies beyond simple all-at-once or basic blue/green: Canary deployments shift a small, fixed percentage of traffic to the new version first (e.g. 10%), wait a specified interval while monitoring for problems, then shift the remaining traffic all at once if no issues are detected. Linear deployments shift traffic in equal, smaller increments at regular intervals (e.g. 10% every 3 minutes) until reaching 100%, providing an even more gradual, cautious rollout than canary's single intermediate step.

Both strategies can be paired with CloudWatch alarms as automatic rollback triggers — if the configured alarm enters an alarm state at any point during the gradual traffic shift, CodeDeploy automatically halts the rollout and reverts all traffic back to the previous, known-good version, containing the blast radius of a bad deployment to whatever small percentage of traffic had already been shifted at the moment the problem was detected.

The choice between canary, linear, and simple all-at-once blue/green is fundamentally a risk-tolerance and deployment-frequency tradeoff: more gradual strategies (linear) provide the smallest possible blast radius for a bad deployment but take longer to complete a full rollout; canary is a middle ground; all-at-once blue/green is fastest but exposes 100% of traffic to a new version immediately once cut over, relying entirely on pre-deployment testing rather than gradual, live traffic verification.

💬 Deep Dive with AI

Key points

  • •Canary: shift a fixed percentage first, wait and monitor, then shift the rest at once
  • •Linear: shift in small, equal increments at regular intervals until 100%, most gradual
  • •Both pair with CloudWatch alarms for automatic rollback if a problem is detected mid-rollout
  • •More gradual strategies minimize blast radius but take longer; all-at-once is fastest but riskiest