AWS › Elastic Load Balancing (ALB, NLB & CLB)
How do target groups and health checks work together within an Application Load Balancer to route traffic only to healthy instances?
IntermediateAnswer
A target group defines a set of registered targets, such as EC2 instances or Lambda functions, along with a health check configuration specifying how the load balancer should periodically verify that each target is functioning correctly, and only targets that pass this health check consistently are considered healthy and eligible to receive traffic, meaning the load balancer automatically and continuously routes around any target that starts failing its health checks.
aws elbv2 create-target-group --name my-targets --protocol HTTP --port 80 --vpc-id vpc-12345 --health-check-path /healthReal-world example A web application configures its target group's health check to hit a dedicated /health endpoint every thirty seconds, and when one instance's application process crashes, the load balancer detects the resulting failed health checks within about a minute and automatically stops routing traffic to that instance.