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.AllAtOncefails if any instance fails: it reports success when even one instance gets the revision. - Believing
CodeDeployDefault.OneAtATimealways 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 isCodeDeployDefault.OneAtATime. - Believing any predefined ECS configuration works with a Network Load Balancer: only
CodeDeployDefault.ECSAllAtOncedoes.