Narrator: Now let's talk about Cross-Zone Balancing.
So let's take an example
of a very imbalanced situation, but
it will illustrate the point.
So we have two availability zones
and the first one has a load balancer with two,
EC2 instances and the second one also
has a load balancer.
So a load balancer instance, obviously
with eight EC2 instances,
the load balancers instances are part of the same,
more general load balancer.
So the client is accessing
these load balancers.
And so with Cross-Zone Load Balancing,
each load balancer
instance will distribute evenly
across all registered instances in all availability zones.
So the client itself
is sending 50% of the traffic
to the first ALB instance and 50% of traffic
to the other ALB instance.
But each ALB is going to redirect that traffic
across all 10 EC2 instances,
regardless of which availability zones they're in.
This is why it's called Cross-Zone Load Balancing.
So if we take a look at the first,
the second ALB, sorry, instance
it's going to send 10%
of the traffic it receives okay,
to all these instances,
because we have 10 instances.
So each of them gets 10% of the traffic
and same story with this first ALB instance,
it's going to send also 10%
of traffic to all these instances.
So in this example, with Cross-Zone balancing,
we are distributing the traffic evenly
across all EC2 instances, and then maybe
something you want to have or not, who knows,
but at least this behavior is available to you.
The second behavior that is available to you is to
not have Cross-Zone balancing.
So we take the same example,
but without Cross-Zone balancing,
the requests or the request sorry,
are distributed in the instances
of the node of the elastic load balancer.
So in this example, what we have
is that the client sends 50% of the traffic to
the first AZ and then 50% of traffic to the second AZ okay.
But the first ALB instance is going to
send the traffic to only these two instances in its region.
So that means that each EC2 instance in this, sorry,
availability zone is going to get
25% of the traffic overall, okay?
So half and half,
and the one on the right-hand side will again
divide up the traffic it receives
into the EC2 instances that are
registered within it's AZ, so AZ 2.
So we can see here
without Cross Load Balancing,
the traffic is contained within each AZ, but
if they are an imbalanced number of
EC2 instances in each AZ,
then some EC2 instances
of a specific AZ will receive more traffic than others.
It's just an option to know about.
There's no right or wrong answer.
It depends on the use case, obviously.
So for the ALB,
Cross-Zone Load Balancing is always on and
you cannot disable it.
And when usually when data goes between
one AZ to another and it will distribute,
you have to pay for it.
But because it's always on and
you can't disable it,
you don't pay for inter AZ data transfers.
For the network load balancer now,
that is disabled by default, but
you pay an amount of dollar if you wanted to enable
Cross-Zone Load Balancing,
And in which case
you will have to pay for the data transfers
between the availability zones.
And finally, the Classic Load Balancer,
which has Cross-Zone Load Balancing disabled by default.
And if you enable it,
there's going to be no charges for inter AZ data transfers.
So all load balancers have this capability.
The ALB is always on
by default, the NLB, you need to enable it and
you're going to pay for it.
And the CLB, you can enable it
and you're not going to pay for it, okay?
So just for the sake of this hands-on,
I've created a CLB and NLB
where you don't have to do it.
I'm just going to show you the settings.
So for the classic load balancer right here,
if I scroll down
all the way down, we have Cross-Zone Load Balancing
that is disabled by default,
but I can change that setting and click on enable it.
And this will evenly distribute the traffic across all my
EC2 instances that are registered
for this classic load balancer.
So here we go,
and I'm not going to pay for it.
For the ALB,
it's always enabled by default.
So there's no setting to change
the Cross-Zone Load Balancing,
because it's always on by default
for the Application Load Balancer.
And for the NLB,
I scroll down and I see that Cross-Zone Load Balancing
is disabled by default.
And I will say, "Okay, I want to enable it."
But here it says, by the way,
you will pay regional data transfer charges because
Cross-Zone Load Balancing is enabled.
And for the NLB,
this is something they will charge you for, okay?
You would click on save
and Cross-Zone Load Balancing will be enabled,
but you will have to pay for it.
That's it, all I want to show you.
So you can just not have to do this hands-on and
I will see you in the next lecture.