Lesson 2 of 3 Elastic Load Balancing

Configuring and Troubleshooting Target Health Checks

This lesson explains how load balancers send traffic only to healthy targets, and why misconfigured health checks are one of the most common causes of outages in exam scenarios.

Learning outcomes

After completing this lesson, you will be able to:

  • Configure health check settings.
  • Explain health states and fail-open behaviour.
  • Fix common causes of unhealthy targets.

Health check settings

Each target group defines a health check protocol and port (the traffic port by default), a path for HTTP and HTTPS checks, an interval (5 to 300 seconds), a timeout, a healthy threshold and unhealthy threshold (consecutive successes or failures), and for ALBs the success codes (200 by default; ranges such as 200-399 are allowed). A good health check path tests that the application can serve requests but does not depend on every downstream system; a check that fails whenever a shared database is slow can mark every target unhealthy at once.

Health states and fail-open behaviour

Targets move through states: initial (registering), healthy, unhealthy, unused (the target's AZ is not enabled or no listener uses the group), draining (deregistering) and unavailable. The describe-target-health output includes a reason code such as Target.Timeout, Target.ResponseCodeMismatch, Target.FailedHealthChecks or Elb.InitialHealthChecking. If all targets in a target group are unhealthy, an ALB fails open and routes to all of them, on the assumption that the health check is wrong. Target group health settings can define minimum healthy counts that trigger DNS failover away from an AZ.

The following diagram compares normal routing with fail-open routing.

How an ALB treats unhealthy targets. Normally it routes only to healthy targets. If every target in the group is unhealthy, it fails open and routes to all of them, assuming the health check rather than the targets is wrong; describe-target-health shows a reason code for each target.
Fail-open behaviour explains why traffic still reaches targets that the console shows as unhealthy.
True or false

Health states

Exam skills 2.2.1

Check how target health states behave.

Log in to try this activity Interactive activities are free with an account.

Common causes of unhealthy targets

The following table lists the reason codes you will see most often and how to fix them.

Reason codeLikely causeFix
Target.TimeoutSecurity group or NACL blocks the load balancer, or the application is not listeningAllow the load balancer's security group on the health check port
Target.ResponseCodeMismatchPath returns 301, 302, 403 or 404Use a path that returns 200, or widen success codes
Target.FailedHealthChecksApplication errors or crashesCheck application logs
Elb.InitialHealthCheckingNew target still being checkedWait, or tune interval and thresholds
Target.NotInUseTarget's AZ not enabled on the load balancerEnable the AZ or move the target
Match the pairs

Health reason codes

Exam skills 2.2.1

Match each reason code with its likely cause.

Log in to try this activity Interactive activities are free with an account.
Worked example

All targets unhealthy after hardening

After a security team replaced a web tier's security group, every target shows Target.Timeout, yet the site still loads intermittently because the ALB fails open. The new security group allows HTTPS from the corporate network only, so the ALB cannot reach the targets on port 8080, the traffic and health check port. Adding an inbound rule that allows port 8080 from the ALB's security group, rather than from a CIDR range, restores health checks and keeps the targets closed to everything else.

Check yourself

What does Target.ResponseCodeMismatch usually indicate?

Show answer

The health check path redirects or does not exist, so the response is not a success code.

Exam Tips

Remember for the exam

  • Health checks use the path, port, interval, thresholds and success codes of the target group.
  • Target.Timeout usually means the security group does not allow the load balancer.
  • Target.ResponseCodeMismatch usually means a redirect or missing path.
  • If all targets are unhealthy, an ALB fails open.
  • Reference the load balancer's security group in target security groups.