AWS Network Load Balancer Basics

user_23708_5a74e69dbae7d.jpg_800.jpg

Image provided courtesy of https://www.awsgeek.com/. Twitter: @awsgeek

INTRODUCTION

AWS has a lot of great features and cutting-edge products, but there are some products that just seem like a “no-brainer” – especially for people who have been working with infrastructure for a long time. One of these products is the “network load balancer.” One of the most glaring absences on the AWS product page has been the Network Load Balancer – until now!

A network load balancer, or “NLB,” is capable of processing traffic and scaling at a much higher rate than the standard application load balancer. Keep in mind, this means a lot of the fancier features of the Application Load Balancer are not available in the Network Load Balancer, such as SSL-offloading, host-based routing, cross-zone load balancing, and others. The complete comparison can be found here.

creating your first Network Load Balancer

So now we know the “why,” let’s move on to the “how!”

Keep in mind, this guide is intended for those who already have some experience deploying load balancers and EC2 instances. The NLB is slightly more advanced, so it’s best that you have some experience first. If you don’t have any experience deploying load balancers in AWS, check out our AWS certification courses, such as the AWS Certified Solutions Architect – Associate Level course.

Deploying an NLB is fairly straightforward, but there are a few different settings that differ from the ALB configuration. Let’s go through a simple NLB configuration and highlight some of these changes.

First, I’m going to go to the EC2 page, click “Load Balancers” on the left, and click “Create Load Balancer” at the top:

user_58180_59f0c454b59d4.png_800.jpg

Once we have done this, we click the blue “create” button in the “Network Load Balancer” section:

user_58180_59f0c47a9463b.png_800.jpg

This screen should look familiar if you have deployed a load balancer before. I am going to name the load balancer “NLB1”, choose “internet-facing” for the scheme, leave the port as default (since we can only use TCP with the NLB), and choose two public subnets:

user_58180_59f0c4945daca.png_800.jpg

By now, you have probably noticed there is a drop-down box for the “Elastic IP.” This is one of the great features of the NLB! You can assign an Elastic IP that will always stay the same for your load balancer. This makes it a lot easier to manage than having to take whatever dynamic IP AWS provides for you. This allows you to create an A record at another DNS host, for instance, and prevent you from having to wait for a variable DNS propagation time if you have to failover to another NLB. Since you know the IP ahead of time, you can assign it anywhere its needed for optimum resilience.

Here, I have assigned two EIPs that I allocated to my environment. If you do not have any EIPs allocated, you can either go allocate them and add them here, or you can allocate them later by associating it with the Elastic Network Interface attached to the NLB. After this has been configured, click “Configure Routing.”:

user_58180_59f0c4be5f3a2.png_800.jpg

Alright, on the “Configure Routing” page, you need to configure your target group and health check settings. I’m going to name my target group “nlbTG” and leave the other settings as default. If you wish to learn more about these settings, we have several courses and lessons that involve load balancing and target groups, such as this hands-on lesson: Creating an Application ELB.

Once you have completed this, click “Next: Register Targets”:

user_58180_59f0c4d82426b.png_800.jpg

Now it’s time to register the targets! I have found that, currently, if you do not register a target, the Network Load Balancer will remain in the “Provisioning” state until you have added a target. Keep this in mind if you are attempting to provision an NLB without targets. So, I am going to select my instance that has a webserver installed and is serving a webpage on port 80 and click “Add to registered.” Following this, we will click “Next: Review.”

user_58180_59f0c4f497c48.png_800.jpg

After reviewing the settings, click “Create”:

user_58180_59f0c50b996af.png_800.jpg

Once the NLB is in the “active” state, we can browse to our EIPs and see that the NLB is routing traffic!

user_58180_59f0c5338b088.png_800.jpg

user_58180_59f0c53b59dbc.png_800.jpg

Now we have our AWS Network Load Balancer all set up and ready to go! Keep in mind that you can always change your Elastic IPs by accessing the “Elastic IPs” section of the EC2 console. This is especially useful if you want to assign an EIP currently assigned to an instance to the NLB instead, which would prevent you from having to modify DNS or hardcoded IPs in your code. If you have more questions about load balancing in AWS, be sure to check out our courses in the AWS section, or leave a comment below!

Resources

https://www.linuxacademy.com
https://www.cloudassessments.com
https://www.aws.com

Looking for team training?