Whenever a target group is unhealthy , I am getting 502 for all the application interface that has been diverted or rerouted to that target group under the Application Load Balancer? Is there any solution to this to direct it to another target group if ec2s or instances under one target group are unhealthy?
1 Answers
No, there is no out of the box solution in target group configuration and ALB.
The load balancer sends a health check request to each registered target every HealthCheckIntervalSeconds seconds, using the specified port, protocol, and ping path. It waits for the target to respond within the response timeout period. If the health checks exceed the threshold for consecutive failed responses, the load balancer takes the target out of service. If no Availability Zone contains a healthy target, the load balancer nodes route requests to all targets. In other words, if all the instances are unhealthy, ELB acts as failing open and will forward the request to all the instances in that target group.**
One option can be the route53 health check but this is different the target group but perform health check against DNS, Amazon Route 53 health checks monitor the health of your resources such as web servers and email servers. Route53 has different option for that purpose.
When you have more than one resource performing the same function—for example, more than one HTTP server or mail server—you can configure Amazon Route 53 to check the health of your resources and respond to DNS queries using only the healthy resources. For example, suppose your website, example.com, is hosted on six servers, two each in three data centers around the world. You can configure Route 53 to check the health of those servers and to respond to DNS queries for example.com using only the servers that are currently healthy.
You can look into the diagram figure.
The preceding diagram illustrates the following sequence of events:
Route 53 receives a query for example.com. Based on the latency for the user making the request, Route 53 selects the latency alias record for the us-east-1 region.
Route 53 selects a weighted record based on weight. Evaluate Target Health is Yes for the latency alias record, so Route 53 checks the health of the selected weighted record.
The health check failed, so Route 53 chooses another weighted record based on weight and checks its health. That record also is unhealthy.
Route 53 backs out of that branch of the tree, looks for the latency alias record with the next-best latency, and chooses the record for ap-southeast-2.
Route 53 again selects a record based on weight, and then checks the health of the selected resource. The resource is healthy, so Route 53 returns the applicable value in response to the query.

- 54,482
- 7
- 145
- 148