Certopolis

AWS Certified CloudOps Engineer – Associate

ALB health checks, fail open and the grace period

The Elastic Load Balancing documentation says an Application Load Balancer sends each registered target a health check every 30 seconds by default and expects the success code 200. Two consecutive failures mark a target unhealthy. If every target in a target group is unhealthy, the load balancer fails open and routes requests to all of them.

What are the default health check settings?

The protocol is HTTP or HTTPS, using the GET method, and the default is HTTP. The default port is the port on which the target receives traffic. The default path is /.

The interval defaults to 30 seconds and the timeout to 5 seconds for instance and IP targets. The healthy threshold defaults to 5 consecutive successes and the unhealthy threshold to 2 consecutive failures.

The matcher, called success codes in the console, defaults to 200. Values from 200 to 499 are allowed, as a list such as 200,202 or a range such as 200-299. A health page that answers with any code outside the matcher fails the check.

What happens when every target is unhealthy?

Each load balancer node normally routes only to healthy targets in its enabled Availability Zones. If a target group contains only unhealthy targets, the load balancer routes to all of them regardless of health status. AWS calls this failing open.

A wrong health check path can therefore mark every target unhealthy while users still get answers. The status values help to tell cases apart: unhealthy means the target failed or did not answer the check, and unused means the target is not registered, its target group is not in a listener rule, it is stopped or terminated, or it is in an Availability Zone that is not enabled for the load balancer.

What does the Auto Scaling health check grace period do?

When an Auto Scaling group uses Elastic Load Balancing health checks, it replaces instances that fail them. The grace period is the minimum time a new instance is kept in service before it can be terminated for being unhealthy. It stops the group from terminating instances that are still initializing.

The default depends on how the group is created: 300 seconds in the console, 0 seconds with the AWS CLI or an SDK. A value of 0 turns the grace period off. With the CLI, pass --health-check-grace-period.

The grace period applies to newly launched instances, instances returned from standby and instances attached by hand. It does not cover an instance that leaves the running state: a stopped instance is marked unhealthy and replaced at once. If launch lifecycle hooks do the initialization, the grace period can be 0.

Where the exam catches people

  • Believing any 2xx or a redirect passes the health check: the default matcher is 200 only.
  • Believing a target group with no healthy targets drops all traffic: the load balancer fails open and routes to every registered target.
  • Assuming the 300-second grace period when creating a group with the CLI or an SDK: the default there is 0.
  • Reading unused as a failed health check: it means the target is not in use, for example its Availability Zone is not enabled for the load balancer.
  • Believing one failed check removes a target: by default it takes 2 consecutive failures, and 5 consecutive successes to return.

Written from these sources

Try 3 questions on this

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

  1. An Auto Scaling group runs four EC2 instances that are registered in one Application Load Balancer target group. A SysOps administrator changes the target group's health check path to /healthz, a page the application does not serve. Soon all four targets show as unhealthy, and an alarm on UnHealthyHostCount goes into ALARM. While the targets are unhealthy, users report no errors and RequestCount does not change. What is a reason for this behavior?

    Right. In the game that’s Renown for your Reliability and Business Continuity building.

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

    Show the full explanation and doc quotes

    The broken health check path made every target look unhealthy at once while the application itself kept answering users, so traffic and user experience did not change even though the alarm fired.

    Written from docs.aws.amazon.com/elasticloadbalancing/latest/application/target-group-health-checks.html

  2. A SysOps administrator creates a target group for EC2 instances behind an Application Load Balancer and leaves every health check setting at its default. The application's health page answers with different HTTP status codes while it starts, runs and shuts down. The team's runbook must state which responses the load balancer counts as a passing health check. Which of the following describes the default behavior?

    Right. In the game that’s Renown for your Reliability and Business Continuity building.

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

    Show the full explanation and doc quotes

    If the page will ever answer healthy with something other than 200, the success codes setting has to be widened to include it.

    Written from docs.aws.amazon.com/elasticloadbalancing/latest/application/target-group-health-checks.html

  3. A SysOps administrator writes a script that creates an Auto Scaling group with the AWS CLI. The group uses Elastic Load Balancing health checks, and the application needs about 4 minutes after boot before it answers the target group's health check. New instances must not be judged on load balancer health until the application is up. An instance that stops running must still be replaced at once. Which action should the SysOps administrator take to meet these requirements?

    Right. In the game that’s Renown for your Reliability and Business Continuity building.

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

    Show the full explanation and doc quotes

    The script must pass it explicitly: a group made through the CLI or an SDK starts with a grace period of 0, unlike the 300-second console default, so without the option every new instance would be condemned during boot. The grace period does not shield an instance that leaves the running state; that one is still marked unhealthy and replaced straight away.

    Written from docs.aws.amazon.com/autoscaling/ec2/userguide/health-check-grace-period.html

Ask for something