1 00:00:00,500 --> 00:00:03,150 Now let's talk about Cross-Zone Balancing. 2 00:00:03,150 --> 00:00:04,360 So let's take an example 3 00:00:04,360 --> 00:00:06,520 of a very imbalanced situation, but 4 00:00:06,520 --> 00:00:08,119 it will illustrate the point. 5 00:00:08,119 --> 00:00:10,130 So we have two availability zones 6 00:00:10,130 --> 00:00:12,490 and the first one has a load balancer with two, 7 00:00:12,490 --> 00:00:14,370 EC2 instances and the second one also 8 00:00:14,370 --> 00:00:15,530 has a load balancer. 9 00:00:15,530 --> 00:00:18,050 So a load balancer instance, obviously 10 00:00:18,050 --> 00:00:19,760 with eight EC2 instances, 11 00:00:19,760 --> 00:00:22,680 the load balancers instances are part of the same, 12 00:00:22,680 --> 00:00:25,090 more general load balancer. 13 00:00:25,090 --> 00:00:27,030 So the client is accessing 14 00:00:27,030 --> 00:00:28,960 these load balancers. 15 00:00:28,960 --> 00:00:32,290 And so with Cross-Zone Load Balancing, 16 00:00:32,290 --> 00:00:33,610 each load balancer 17 00:00:33,610 --> 00:00:35,520 instance will distribute evenly 18 00:00:35,520 --> 00:00:39,290 across all registered instances in all availability zones. 19 00:00:39,290 --> 00:00:41,220 So the client itself 20 00:00:41,220 --> 00:00:43,400 is sending 50% of the traffic 21 00:00:43,400 --> 00:00:46,810 to the first ALB instance and 50% of traffic 22 00:00:46,810 --> 00:00:49,070 to the other ALB instance. 23 00:00:49,070 --> 00:00:52,610 But each ALB is going to redirect that traffic 24 00:00:52,610 --> 00:00:55,310 across all 10 EC2 instances, 25 00:00:55,310 --> 00:00:58,440 regardless of which availability zones they're in. 26 00:00:58,440 --> 00:01:01,150 This is why it's called Cross-Zone Load Balancing. 27 00:01:01,150 --> 00:01:03,450 So if we take a look at the first, 28 00:01:03,450 --> 00:01:05,473 the second ALB, sorry, instance 29 00:01:05,473 --> 00:01:08,040 it's going to send 10% 30 00:01:08,040 --> 00:01:09,980 of the traffic it receives okay, 31 00:01:09,980 --> 00:01:12,750 to all these instances, 32 00:01:12,750 --> 00:01:14,120 because we have 10 instances. 33 00:01:14,120 --> 00:01:16,890 So each of them gets 10% of the traffic 34 00:01:16,890 --> 00:01:20,480 and same story with this first ALB instance, 35 00:01:20,480 --> 00:01:21,790 it's going to send also 10% 36 00:01:21,790 --> 00:01:23,860 of traffic to all these instances. 37 00:01:23,860 --> 00:01:26,650 So in this example, with Cross-Zone balancing, 38 00:01:26,650 --> 00:01:29,150 we are distributing the traffic evenly 39 00:01:29,150 --> 00:01:31,970 across all EC2 instances, and then maybe 40 00:01:31,970 --> 00:01:34,300 something you want to have or not, who knows, 41 00:01:34,300 --> 00:01:37,730 but at least this behavior is available to you. 42 00:01:37,730 --> 00:01:40,290 The second behavior that is available to you is to 43 00:01:40,290 --> 00:01:42,470 not have Cross-Zone balancing. 44 00:01:42,470 --> 00:01:44,850 So we take the same example, 45 00:01:44,850 --> 00:01:46,930 but without Cross-Zone balancing, 46 00:01:46,930 --> 00:01:49,060 the requests or the request sorry, 47 00:01:49,060 --> 00:01:50,950 are distributed in the instances 48 00:01:50,950 --> 00:01:53,950 of the node of the elastic load balancer. 49 00:01:53,950 --> 00:01:55,430 So in this example, what we have 50 00:01:55,430 --> 00:01:58,610 is that the client sends 50% of the traffic to 51 00:01:58,610 --> 00:02:02,400 the first AZ and then 50% of traffic to the second AZ okay. 52 00:02:02,400 --> 00:02:05,920 But the first ALB instance is going to 53 00:02:05,920 --> 00:02:09,800 send the traffic to only these two instances in its region. 54 00:02:09,800 --> 00:02:12,890 So that means that each EC2 instance in this, sorry, 55 00:02:12,890 --> 00:02:14,610 availability zone is going to get 56 00:02:14,610 --> 00:02:16,840 25% of the traffic overall, okay? 57 00:02:16,840 --> 00:02:18,090 So half and half, 58 00:02:18,090 --> 00:02:20,140 and the one on the right-hand side will again 59 00:02:20,140 --> 00:02:21,800 divide up the traffic it receives 60 00:02:21,800 --> 00:02:23,850 into the EC2 instances that are 61 00:02:23,850 --> 00:02:26,350 registered within it's AZ, so AZ 2. 62 00:02:26,350 --> 00:02:27,790 So we can see here 63 00:02:27,790 --> 00:02:29,700 without Cross Load Balancing, 64 00:02:29,700 --> 00:02:32,800 the traffic is contained within each AZ, but 65 00:02:32,800 --> 00:02:35,100 if they are an imbalanced number of 66 00:02:35,100 --> 00:02:37,360 EC2 instances in each AZ, 67 00:02:37,360 --> 00:02:39,380 then some EC2 instances 68 00:02:39,380 --> 00:02:42,730 of a specific AZ will receive more traffic than others. 69 00:02:42,730 --> 00:02:44,720 It's just an option to know about. 70 00:02:44,720 --> 00:02:46,080 There's no right or wrong answer. 71 00:02:46,080 --> 00:02:48,800 It depends on the use case, obviously. 72 00:02:48,800 --> 00:02:50,350 So for the ALB, 73 00:02:50,350 --> 00:02:53,120 Cross-Zone Load Balancing is always on and 74 00:02:53,120 --> 00:02:54,760 you cannot disable it. 75 00:02:54,760 --> 00:02:57,520 And when usually when data goes between 76 00:02:57,520 --> 00:02:59,157 one AZ to another and it will distribute, 77 00:02:59,157 --> 00:03:00,570 you have to pay for it. 78 00:03:00,570 --> 00:03:01,970 But because it's always on and 79 00:03:01,970 --> 00:03:02,850 you can't disable it, 80 00:03:02,850 --> 00:03:05,513 you don't pay for inter AZ data transfers. 81 00:03:06,460 --> 00:03:08,544 For the network load balancer now, 82 00:03:08,544 --> 00:03:11,052 that is disabled by default, but 83 00:03:11,052 --> 00:03:15,470 you pay an amount of dollar if you wanted to enable 84 00:03:15,470 --> 00:03:16,540 Cross-Zone Load Balancing, 85 00:03:16,540 --> 00:03:17,430 And in which case 86 00:03:17,430 --> 00:03:19,720 you will have to pay for the data transfers 87 00:03:19,720 --> 00:03:22,070 between the availability zones. 88 00:03:22,070 --> 00:03:24,160 And finally, the Classic Load Balancer, 89 00:03:24,160 --> 00:03:27,260 which has Cross-Zone Load Balancing disabled by default. 90 00:03:27,260 --> 00:03:28,320 And if you enable it, 91 00:03:28,320 --> 00:03:32,360 there's going to be no charges for inter AZ data transfers. 92 00:03:32,360 --> 00:03:34,660 So all load balancers have this capability. 93 00:03:34,660 --> 00:03:37,120 The ALB is always on 94 00:03:37,120 --> 00:03:39,490 by default, the NLB, you need to enable it and 95 00:03:39,490 --> 00:03:40,590 you're going to pay for it. 96 00:03:40,590 --> 00:03:42,400 And the CLB, you can enable it 97 00:03:42,400 --> 00:03:45,030 and you're not going to pay for it, okay? 98 00:03:45,030 --> 00:03:46,760 So just for the sake of this hands-on, 99 00:03:46,760 --> 00:03:48,310 I've created a CLB and NLB 100 00:03:48,310 --> 00:03:49,840 where you don't have to do it. 101 00:03:49,840 --> 00:03:51,170 I'm just going to show you the settings. 102 00:03:51,170 --> 00:03:53,600 So for the classic load balancer right here, 103 00:03:53,600 --> 00:03:54,740 if I scroll down 104 00:03:54,740 --> 00:03:56,750 all the way down, we have Cross-Zone Load Balancing 105 00:03:56,750 --> 00:03:58,390 that is disabled by default, 106 00:03:58,390 --> 00:04:01,260 but I can change that setting and click on enable it. 107 00:04:01,260 --> 00:04:04,250 And this will evenly distribute the traffic across all my 108 00:04:04,250 --> 00:04:06,470 EC2 instances that are registered 109 00:04:06,470 --> 00:04:07,760 for this classic load balancer. 110 00:04:07,760 --> 00:04:08,593 So here we go, 111 00:04:08,593 --> 00:04:10,690 and I'm not going to pay for it. 112 00:04:10,690 --> 00:04:12,060 For the ALB, 113 00:04:12,060 --> 00:04:13,900 it's always enabled by default. 114 00:04:13,900 --> 00:04:16,100 So there's no setting to change 115 00:04:16,100 --> 00:04:17,279 the Cross-Zone Load Balancing, 116 00:04:17,279 --> 00:04:18,640 because it's always on by default 117 00:04:18,640 --> 00:04:20,050 for the Application Load Balancer. 118 00:04:20,050 --> 00:04:21,510 And for the NLB, 119 00:04:21,510 --> 00:04:24,110 I scroll down and I see that Cross-Zone Load Balancing 120 00:04:24,110 --> 00:04:25,820 is disabled by default. 121 00:04:25,820 --> 00:04:27,800 And I will say, "Okay, I want to enable it." 122 00:04:27,800 --> 00:04:29,380 But here it says, by the way, 123 00:04:29,380 --> 00:04:31,500 you will pay regional data transfer charges because 124 00:04:31,500 --> 00:04:33,470 Cross-Zone Load Balancing is enabled. 125 00:04:33,470 --> 00:04:34,310 And for the NLB, 126 00:04:34,310 --> 00:04:36,540 this is something they will charge you for, okay? 127 00:04:36,540 --> 00:04:37,920 You would click on save 128 00:04:37,920 --> 00:04:39,910 and Cross-Zone Load Balancing will be enabled, 129 00:04:39,910 --> 00:04:41,300 but you will have to pay for it. 130 00:04:41,300 --> 00:04:42,670 That's it, all I want to show you. 131 00:04:42,670 --> 00:04:45,170 So you can just not have to do this hands-on and 132 00:04:45,170 --> 00:04:46,920 I will see you in the next lecture.