Canary Releases

Send a small slice of traffic to the new version first, then ramp up if metrics look healthy.

A canary release shifts traffic gradually. You send a small percentage β€” say 10% β€” to the new version and watch error rates and latency. If everything looks good, you ramp to 50%, then 100%. If metrics degrade, you roll back having only affected a handful of users.

Where it shines

  • High-traffic services where even a brief bad release hurts many users.
  • Changes you cannot fully validate in staging.

CodeDeploy offers built-in canary configurations for Lambda and ECS, such as 10% for 5 minutes, then all at once, with automatic rollback tied to CloudWatch alarms.

Example

Example Β· bash
# Shift 10% of Lambda traffic to the new version, then the rest after 5 min
aws deploy create-deployment \
  --application-name myapp \
  --deployment-group-name prod \
  --deployment-config-name CodeDeployDefault.LambdaCanary10Percent5Minutes

When to use it

  • A team sends 5% of production traffic to a new Lambda version and monitors error rates for 10 minutes before shifting the remaining 95%.
  • A company uses a canary release to test a new pricing algorithm with 1% of users before rolling it out globally, limiting financial risk.
  • An ops engineer configures CodeDeploy linear traffic shifting so 10% of users are moved to the new version every minute over a 10-minute window.

More examples

Lambda canary via weighted alias

Publishes a new Lambda version and updates the prod alias to route 10% of invocations to it as a canary.

Example Β· bash
# Publish a new Lambda version
NEW_VER=$(aws lambda publish-version \
  --function-name myapp \
  --query 'Version' --output text)

# Shift 10% of alias traffic to the new version
aws lambda update-alias \
  --function-name myapp \
  --name prod \
  --routing-config AdditionalVersionWeights={"$NEW_VER"=0.1}

CodeDeploy linear canary config

Creates a deployment config that shifts 10% of traffic per minute so a full rollout takes 10 minutes with monitoring windows.

Example Β· bash
aws deploy create-deployment-config \
  --deployment-config-name Linear10PercentEvery1Minute \
  --traffic-routing-config \
    type=TimeBasedLinear,timeBasedLinear='{linearPercentage=10,linearInterval=1}'

Promote Lambda canary to 100%

Completes the canary by pointing the prod alias entirely to the new version, removing the traffic split.

Example Β· bash
# After verifying metrics, shift all traffic to the new version
aws lambda update-alias \
  --function-name myapp \
  --name prod \
  --function-version $NEW_VER \
  --routing-config AdditionalVersionWeights={}

Discussion

  • Be the first to comment on this lesson.
Canary Releases β€” AWS Deployment | SoundsCode