I enabled my Elastic Load Balancer (ELB) for two Availability Zones, but it shows only one IP address in DNS.
Short description
With Application Load Balancers, cross-zone load balancing is always enabled. However, with Network Load Balancers and Gateway Load Balancers, cross-zone load balancing is disabled by default.
When cross-zone load balancing is disabled, an Availability Zone must have at least one healthy target in each target group. When cross-zone load balancing is enabled, an Availability Zone can have at least one healthy target in each target group in any Availability Zone. Each condition keeps the Availability Zone healthy, and lets you add the corresponding Network Load Balancer node IP address to the Network Load Balancer DNS.
Resolution
When cross-zone load balancing is disabled
The following is an example of when cross-zone load balancing is disabled between two Availability Zones, AZ1 and AZ2.
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.
Network Load Balancer includes only the IP address of AZ2 in the Network Load Balancer DNS because AZ2 is the only healthy Availability Zone. As a result, when you resolve the domain of the Network Load Balancer, the IP address of AZ2 is the only one that appears.
Traffic then gets routed through the Network Load Balancer node in AZ2 to the healthy target in the corresponding target group. If there are multiple healthy targets in a target group, then one target is selected based on the routing algorithm of the load balancer.
If both Availability Zones are unhealthy, then the Network Load Balancer fails open. Each Network Load Balancer IP address is then added to the DNS of the load balancer.
When cross-zone load balancing is enabled
The following is an example of when cross-zone load balancing is enabled using the same Availability Zones, AZ1 and AZ2:
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, Network Load Balancer includes both IP addresses in the DNS for the Network Load Balancer hostname.
Traffic then gets routed to any of the Network Load Balancers 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.
If target B1 in AZ1 is unhealthy and target B2 in AZ2 is also unhealthy, then both Availability Zones are unhealthy. Because neither Availability Zone is healthy, the Network Load Balancer fails open. Each Network Load Balancer 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.