I configured my Elastic Load Balancer (ELB) for two Availability Zones, but it shows only one IP address in DNS.
Short description
With default ELB settings, DNS can omit IP addresses for your ELB load balancers if cross-zone load balancing is turned off. Then, if an Availability Zone contains a target group that doesn't have at least one healthy target, the IP address for that zone is omitted.
You can change ELB thresholds for target group health evaluation, with a minimum count or percentage of targets that must be healthy.
Note: With Application Load Balancers, cross-zone load balancing is always turned on at load balancer level. You can't turn off cross-zone load balancing, but you can change it at the target group level. With Network Load Balancers and Gateway Load Balancers, cross-zone load balancing is turned off by default. You can turn on cross-zone load balancing for Network Load Balancers at the target group level. You can turn on cross-zone load balancing for Gateway Load Balancers at the load balancer level.
With Application Load Balancers, an empty target group might not report an error and therefore can appear healthy. This includes the zonal view of the target group when cross-zone load balancing is off. With Network Load Balancers, an empty target group is reported as unhealthy.
Resolution
When cross-zone load balancing is turned off
If cross-zone load balancing is turned off and only one Availability Zone is healthy, then DNS shows only one load balancer node.
For example:
- One Availability Zone 1 (AZ1) has two target groups, A and B, each with its own target, A1 and B1. Target A1 is unhealthy and target B1 is healthy. Because target A1 is unhealthy, AZ1 is also unhealthy.
- Availability Zone 2 (AZ2) also has two target groups, A and B, each with its own target, A2 and B2. Targets A2 and B2 are both healthy. Because each target in both target groups is healthy, AZ2 is healthy.
In this case, only the IP address of AZ2 is included in the load balancer's DNS because AZ2 is the only healthy Availability Zone. As a result, when you resolve the domain of the load balancer, the IP address of AZ2 is the only one that appears.
If cross-zone load balancing is turned off and both Availability Zones are unhealthy, then the load balancer fails open. Both load balancer IP addresses appear in DNS.
When cross-zone load balancing is turned on
If cross-zone load balancing is turned on, then DNS always shows IP addresses for both load balancer nodes.
For example, one target can be unhealthy:
- In AZ1, target A1 is unhealthy and target B1 is healthy.
- In AZ2, both targets A2 and B2 are healthy.
Because each Availability Zone has at least one healthy target, ELB includes both IP addresses in the DNS for the load balancer.
Traffic then gets routed to any of the load balancer nodes and forwarded to the targets in the corresponding target groups. If there are multiple healthy targets in a target group, then a target is selected based on the routing algorithm of the load balancer.
Or, all targets can be unhealthy:
- In AZ1, target A1 is unhealthy and target B1 is unhealthy.
- In AZ2, target A2 is unhealthy and target B2 is unhealthy.
If all targets are unhealthy, then both Availability Zones are unhealthy and the load balancer fails open. Each ELB IP address is then added to the DNS of the load balancer. As a result, when you resolve the domain, the IP addresses for both Availability Zones appear.
Related information
How Elastic Load Balancing works