What is Cross-Zone Load Balancing?
As per the AWS Documentation:
“With cross-zone load balancing, each load balancer node distributes requests evenly across the registered instances in all enabled Availability Zones. If cross-zone load balancing is disabled, each load balancer node distributes requests evenly across the registered instances in its Availability Zone only.”
In simpler terms, in a Multi-AZ setup, if cross-zone load balancing is not enabled, the load balancer only forwards traffic to targets within the same AZ where the request started.
Image Ref: AWS Docs
In the above image, you can see:
- Each target in Availability Zone A is serving traffic 25% of the traffic, while each target in Availability Zone B is serving only 6.25% of it.
However, with cross-zone load balancing, traffic is distributed across all registered targets, regardless of the availability zones they are in.
And if you consider the same target setup with a cross-zone load balancing setup, you can see that each of the 10 targets receives 10% of the traffic.
Image Ref: AWS Docs
If you are using Application Load Balancer, cross-zone load balancing is enabled for you by default.
In case you are using Network Load Balancer, You need to enable the cross-zone load balancing as it comes as disabled by default.
But why need CrossZone Loadbalancing?
It helps in utilizing the registered targets more efficiently.
It helps in improved fault tolerance, if one zone fails, the other zone is already ready to serve traffic.