Certopolis

AWS Certified DevOps Engineer – Professional

CodeDeploy deployment configurations: canary vs linear (DOP-C02)

A deployment configuration is the set of rules CodeDeploy uses to decide how fast a deployment moves and when it has succeeded. The CodeDeploy User Guide says that on EC2 it sets the minimum healthy hosts, and on Lambda and ECS it sets how traffic shifts: canary, linear or all at once.

The three predefined EC2 configurations

CodeDeployDefault.AllAtOnce tries to deploy to as many instances as possible at the same time. The deployment is reported as succeeded if the revision installs on at least one instance, and fails only if every instance fails.

CodeDeployDefault.HalfAtATime deploys to up to half of the instances at a time, rounded down, and succeeds if at least half of the instances, rounded up, get the revision. With nine instances it works on four at a time and needs five successes.

CodeDeployDefault.OneAtATime deploys to one instance at a time and fails as soon as any instance but the last one fails. If only the last instance fails, the deployment still succeeds. In a group of one instance, that instance must succeed. This is the configuration CodeDeploy uses when you name none.

Canary vs linear for Lambda and ECS

A canary configuration shifts traffic in two steps. CodeDeployDefault.LambdaCanary10Percent5Minutes sends 10 percent first and the other 90 percent five minutes later. Lambda has canary configurations with waits of 5, 10, 15 and 30 minutes. ECS has two: ECSCanary10Percent5Minutes and ECSCanary10Percent15Minutes.

A linear configuration shifts traffic in equal steps with the same wait between them. CodeDeployDefault.LambdaLinear10PercentEvery2Minutes moves 10 percent every two minutes until all traffic has moved. Lambda has linear configurations with steps every 1, 2, 3 and 10 minutes. ECS has steps every 1 and 3 minutes.

CodeDeployDefault.LambdaAllAtOnce and CodeDeployDefault.ECSAllAtOnce move all traffic in one step. With a Network Load Balancer, CodeDeployDefault.ECSAllAtOnce is the only predefined ECS configuration that is supported.

When do you need a custom configuration?

You can create your own configuration on all three compute platforms. On EC2 a custom configuration sets its own minimum healthy hosts value, as a number or a percentage of instances. None of the predefined configurations sets a minimum number of healthy hosts per Availability Zone, so that feature always needs a custom configuration.

For Lambda and ECS you can create custom canary or linear configurations. The exception is an ECS blue/green deployment managed through CloudFormation, where custom canary and linear configurations cannot be created.

Where the exam catches people

  • Believing CodeDeployDefault.AllAtOnce fails if any instance fails: it reports success when even one instance gets the revision.
  • Believing CodeDeployDefault.OneAtATime always requires every instance to succeed: in a group of more than one instance, a failure on the last instance still counts as success.
  • Believing a canary keeps every step small: after the first 10 percent, the second step moves the remaining 90 percent at once. Only linear keeps every step at 10 percent.
  • Believing a deployment group with no configuration named uses AllAtOnce: the default is CodeDeployDefault.OneAtATime.
  • Believing any predefined ECS configuration works with a Network Load Balancer: only CodeDeployDefault.ECSAllAtOnce does.

Written from these sources

Try 3 questions on this

Pick an answer to see why each option is right or wrong.

  1. A company's DevOps team uses AWS CodeDeploy in-place deployments to release an internal application to a test environment of 12 Amazon EC2 instances. Testers accept that the test application is unavailable while a release is installed. The team wants every release to reach all 12 instances as fast as possible, and it wants to use one of the predefined deployment configurations rather than create its own. The test environment's deployment group currently names no deployment configuration. Which solution will meet these requirements?

    Right. In the game that’s Renown for your SDLC Automation building.

    Not that one: C is right. In the game your SDLC Automation building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    CodeDeployDefault.AllAtOnce tries to deploy to as many instances as possible at the same time, which is exactly what a test fleet that can tolerate downtime wants, and it is predefined, so nothing has to be created.

    Written from docs.aws.amazon.com/codedeploy/latest/userguide/deployment-configurations.html

  2. A company deploys a payment authorization service as an Amazon ECS service behind an Application Load Balancer, using AWS CodeDeploy blue/green deployments. A recent release passed every test, but about ten minutes after it began taking traffic, expiring cache entries exposed a defect and customers saw errors. For future releases, no more than a tenth of requests may reach a new task set until that ten-minute window has passed, each release must finish within 20 minutes, and the team wants a predefined deployment configuration. Which solution will meet these requirements?

    Right. In the game that’s Renown for your SDLC Automation building.

    Not that one: A is right. In the game your SDLC Automation building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    A canary that sends 10 percent of traffic and waits 15 minutes before moving the rest does both: the window passes with only a tenth of requests exposed, and the last shift lands at 15 minutes. Linear shifts keep adding traffic every few minutes, and the shorter canary moves everyone before the problem can appear.

    Written from docs.aws.amazon.com/codedeploy/latest/userguide/deployment-configurations.html

  3. A company releases an AWS Lambda function with AWS CodeDeploy, which shifts traffic on the function's live alias. Each version opens new connections to a shared database when it starts taking invocations, and the database team requires that no single traffic change move more than 10 percent of invocations. A CloudWatch alarm on the new version's errors is attached to the deployment group with rollback on alarm, and it needs 90 seconds of data after a traffic change to evaluate that change. Each release must finish within 25 minutes, and the team wants a predefined deployment configuration. Which solution will meet these requirements?

    Right. In the game that’s Renown for your SDLC Automation building.

    Not that one: C is right. In the game your SDLC Automation building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    Among the linear options, two minutes between steps gives the alarm its 90 seconds of data after each change, and ten increments two minutes apart reach full traffic in about 18 minutes, inside the 25-minute limit.

    Written from docs.aws.amazon.com/codedeploy/latest/userguide/deployment-configurations.html

Ask for something