Certopolis

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, with rollback on.
  • Believing a healthy task between failures never matters: with the default resetOnHealthyTask of true the failure count returns to 0. Set it to false to count all failures.
  • Believing BOUNDED_PERCENT 50 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 minimumHealthyPercent 90 and maximumPercent 110 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

Try 3 questions on this

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

  1. An Amazon ECS service uses the rolling update deployment controller with the deployment circuit breaker and rollback turned on, and its desired count stays at 12 tasks. In a bad deployment, a few new tasks fail to start, then one task starts and passes its health checks, and then more tasks fail. A deployment must fail and roll back as soon as 6 task failures have occurred in total. Which solutions will meet these requirements? (Select TWO.)

    Right. In the game that’s Renown for your Testing and Deployment building.

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

    Show the full explanation and doc quotes

    The threshold must then be 6: type COUNT with a value of 6 sets it directly, and type BOUNDED_PERCENT with a value of 50 multiplies 50% by the desired count of 12, which is 6, inside the 3-200 bounds.

    Written from docs.aws.amazon.com/AmazonECS/latest/developerguide/deployment-circuit-breaker.html

  2. A checkout service runs as an Amazon ECS service that uses rolling updates behind an Application Load Balancer. A release last week passed all container and target group health checks, yet a pricing defect made the targets answer 18 percent of checkout calls with HTTP 5XX responses for 40 minutes. Releases that push target 5XX responses above a set level must now fail and return to the previous service revision on their own. Which solution will meet these requirements?

    Right. In the game that’s Renown for your Testing and Deployment building.

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

    Show the full explanation and doc quotes

    Naming an alarm on the target group's HTTPCode_Target_5XX_Count metric in the service's deployment configuration, with rollback turned on, makes Amazon ECS fail the deployment when the alarm enters ALARM and return the service to the last completed deployment.

    Written from docs.aws.amazon.com/AmazonECS/latest/developerguide/deployment-alarm-failure.html

  3. A company runs an Amazon ECS service behind an Application Load Balancer. For each release, the company wants 10 percent of production traffic to go to the new service revision for 15 minutes of observation, and then all of the remaining traffic to move to the new revision at once. Which solution will meet these requirements?

    Right. In the game that’s Renown for your Testing and Deployment building.

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

    Show the full explanation and doc quotes

    A 10.0 canary percentage with a 15-minute canary bake time is exactly the release pattern described.

    Written from docs.aws.amazon.com/AmazonECS/latest/developerguide/canary-deployment.html

Ask for something