AWS Certified Developer – Associate
ECS deployments: circuit breaker, alarms, canary (DVA-C03)
The Amazon ECS Developer Guide says a rolling update replaces running tasks within minimumHealthyPercent and maximumPercent. Two methods fail a bad rolling deployment: the deployment circuit breaker, for tasks that cannot start or stay healthy, and CloudWatch alarms, for application metrics. Both can roll back. A canary deployment shifts a small traffic percentage first, then the rest.
How does a rolling update replace tasks?
The DVA-C03 exam guide lists deploying containerized applications with Amazon ECS task definitions, Amazon EKS manifests, AWS Fargate and rolling updates as content added to Task 3.3.
With the rolling update (ECS) deployment type the service scheduler replaces running tasks with new ones. minimumHealthyPercent is the lower limit of tasks that must stay running, as a percent of the desired count, rounded up. maximumPercent is the upper limit, rounded down. Example: desired count 4 with a minimum of 50 lets the scheduler stop two tasks before starting two new ones. A maximum of 200 lets it start four new tasks before stopping four old ones.
The values must let the scheduler stop or start at least one task. A desired count of 2 with a minimum of 75 percent rounds up to 2, so no task can be stopped.
healthCheckGracePeriodSeconds is the time after a task first starts during which the scheduler ignores unhealthy Elastic Load Balancing, VPC Lattice and container health checks. The default is 0. A service whose tasks take minutes to respond needs a grace period, or the scheduler marks the tasks unhealthy and stops them.
Circuit breaker vs CloudWatch alarms
The deployment circuit breaker decides whether the tasks reach a steady state. It counts tasks that fail to reach RUNNING, then tasks replaced because of failed load balancer, AWS Cloud Map or container health checks. When the count equals the threshold, the deployment is marked FAILED. With rollback set to true, the service returns to the most recent deployment in the COMPLETED state.
The threshold comes from thresholdConfiguration. The default type is BOUNDED_PERCENT with a value of 50: the value is multiplied by the desired count, rounded up, and held between 3 and 200. UNBOUNDED_PERCENT has no bounds. COUNT uses the value directly. Example: desired count 12 with BOUNDED_PERCENT 50 gives a threshold of 6, the same as COUNT 6.
resetOnHealthyTask defaults to true, so the failure count resets to 0 each time a task becomes healthy and only consecutive failures count. Set to false, failures accumulate for the whole deployment.
For the alarm method you list CloudWatch alarm names under alarms in the deployment configuration. Amazon ECS sets the deployment to failed when a listed alarm goes into ALARM, and rolls back to the last completed deployment if rollback is on. If an alarm is already in ALARM when the deployment starts, Amazon ECS does not monitor alarms for that deployment. Both methods are supported only with the rolling update (ECS) deployment controller. They can be used together, and whichever criteria is met first fails the deployment.
Canary traffic shifting and lifecycle hooks
A canary deployment runs the current (blue) and new (green) service revisions side by side behind load balancer target groups. Production traffic shifts in two steps: first the canary percentage, then 100 percent. The canary bake time is how long Amazon ECS waits after the first step. The deployment bake time is how long both revisions keep running after all production traffic has shifted, before the old revision is terminated.
Example: 10 percent of traffic to the new revision for 15 minutes and then the rest at once is a canary percentage of 10.0 with a canary bake time of 15 minutes.
Lifecycle hooks run at stages such as POST_TEST_TRAFFIC_SHIFT and PRE_PRODUCTION_TRAFFIC_SHIFT. A Lambda hook runs your function. A pause hook stops the deployment until someone calls ContinueServiceDeployment with the hookId and an action of CONTINUE or ROLLBACK. The default pause timeout is 1,440 minutes and the default timeout action is ROLLBACK. For linear and canary deployments, a pause hook at PRE_PRODUCTION_TRAFFIC_SHIFT is invoked at each traffic shift step.
Where the exam catches people
- Believing the circuit breaker catches a release that passes health checks but returns HTTP 5XX: the circuit breaker watches task starts and health checks. A CloudWatch alarm in the deployment configuration covers application metrics.
- Believing an alarm with an SNS action rolls the service back: the alarm must be named in the service's deployment configuration
alarms, withrollbackon. - Believing a healthy task between failures never matters: with the default
resetOnHealthyTaskof true the failure count returns to 0. Set it to false to count all failures. - Believing
BOUNDED_PERCENT50 always means half the desired count: the result is held to a minimum of 3 and a maximum of 200. - Believing a rolling update with
minimumHealthyPercent90 andmaximumPercent110 sends 10 percent of traffic to the new revision: those values limit task counts. Canary percentage and canary bake time control the traffic split.
Written from these sources
- Deploy Amazon ECS services by replacing tasks
- How the Amazon ECS deployment circuit breaker detects failures
- How CloudWatch alarms detect Amazon ECS deployment failures
- Amazon ECS canary deployments
- Pause hooks for Amazon ECS service deployments
- Amazon ECS service definition parameters
- Comparison of DVA-C02 and DVA-C03