Get startedGet started for free

Canary and linear deployments

1. Canary and linear deployments

Welcome back! In this video, you'll learn canary and linear traffic shifting, deploy a Lambda function with a canary configuration, and wire CloudWatch alarms for automatic rollback. Let's get started.

2. One bad release, every user

Imagine deploying a payment-processing change to your Lambda function. You push it, and a hundred percent of traffic shifts immediately. Five seconds later, a bug fails every checkout. Ten minutes pass before someone notices. Now imagine you'd routed ten percent of traffic for the first five minutes. The bug would have surfaced in a sliver of users while a CloudWatch alarm triggered automatic rollback.

3. What is a canary deployment

A canary deployment routes a small slice of traffic to the new version, then waits before sending the rest. The classic pattern is ten percent of traffic for five or ten minutes. During that wait, you watch error rates and latency. If everything looks good, the remaining ninety percent shifts at once. If something goes wrong, you stop the deployment and only a fraction of users are affected. The name comes from canaries in coal mines, early warning at low cost.

4. What is a linear deployment

A linear deployment shifts traffic in equal-sized steps with a wait between each step. A common pattern is ten percent every one minute, which fully shifts traffic over ten minutes. Each step gives metrics time to react before more traffic moves over. Linear is smoother than canary because every increment is the same size, but it takes longer to fully cut over. It's a good fit when you want a steady ramp without a single big jump at the end.

5. Canary vs. linear, side by side

Canary and linear are both gradual rollouts, but they shape traffic differently. Canary sends a small slice first, then jumps to the rest after a wait. Linear shifts in many equal steps. Canary catches catastrophic problems with the smallest user impact, because if the canary slice fails, the rest never goes out. Linear gives you a smoother ramp, useful when you want to watch metrics evolve over time. Either way, an automatic trigger can stop the rollout mid-flight and roll back.

6. CodeDeploy configurations for Lambda

For Lambda, CodeDeploy ships built-in deployment configurations, all prefixed with CodeDeployDefault. The names on screen read like a formula: the traffic-shift shape, the percentage, and the interval. Take a payments Lambda used by the checkout API. A change to the payment logic is high risk, so you would reach for the canary option shown first: ten percent of traffic for five minutes while CloudWatch alarms watch the error rate, then the full rollout. The linear options ramp traffic in even steps instead, and the all-at-once option sends full traffic immediately for low-risk changes. ECS offers the same shapes under ECS-prefixed names.

7. Automatic rollback with CloudWatch alarms

You don't have to babysit a deployment. CodeDeploy lets you attach CloudWatch alarms to a deployment group. Common alarms watch Lambda Errors, Lambda Duration, or API Gateway 5xx counts. If any attached alarm enters the ALARM state during the deployment, CodeDeploy stops the rollout and rolls back to the previous version automatically. This turns "watch the dashboard" into "go to lunch and trust the alarm." It's especially powerful with canary or linear configurations.

8. Picking the right configuration

Match the configuration to the risk profile. A routine, well-tested patch can go out all at once, fast and simple. Canary is the safe choice when a change is high risk, because problems surface while user impact is still tiny. Linear sits in between, ramping traffic in steady steps so you can watch metrics evolve. Whichever shape you pick, attach CloudWatch alarms so rollback is automatic. Strategy plus alarms is what makes safe deploys possible.

9. Let's practice!

Now let's pick a configuration and watch it roll out. Let's practice!

Create Your Free Account

or

By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.