Load balancers are a beneficial technology since they increase the availability of any web-based application or website. 

For example, when multiple clients attempt to access your web application, they may not be able to reach it if the number of accessors is very high. 

Here’s where load balancers step in. 

They act as distributors, dispensing the incoming traffic across many targets (for example, Amazon EC2 instances, IP addresses, containers, etc.). In this blog, we will discuss how to create Network and Application Load Balancers in AWS. 

So without any further ado, let’s dive right in! 

What is a Network Load Balancer? 

A Network Load Balancer (NLB) works at layer 4 of the Network Protocol. It can handle both TCP and UDP, as well as TCP connections encrypted with TLS. 

Its main feature is high performance. Also, it uses static IP addresses and can be assigned Elastic IPs—not possible with ALB (Application Load Balancer) or ELB (Elastic Load Balancing). 

If you are using container services and/or want to support more than one port on an EC2 instance, NLB is especially well suited to ECS (The Amazon EC2 Container Service). On that note, let’s find out how to create a Network Load Balancer. 

How to Create a Network Load Balancer in AWS? 

Follow these steps to create a Network Load Balancer in AWS. 

Step 1: Log in to the console https://console.aws.amazon.com/ec2/

Step 2: In the left navigation panel, under Load Balancing, choose Target Groups.

https://lh3.googleusercontent.com/vaTNLNgX5v2HVIkGudnD4iQjCAQ8Vtqw1Y4atbj6qgPVqxkKKlXFYYz0Atgee0XzSl43iumQKYyoaRCyo9u3hjcpYCJK8vJzWXeS9XTf013KzGUytiksvQV3IjTR2C9ltOC4_eTm
 Choosing the target groups

Step 3: Click on create Target Group. Over there, you can select the target type. Select Instance to specify targets by instance ID or IP addresses to specify targets by IP address.

https://lh3.googleusercontent.com/vhumAgREjte0q7NP7DJvUuf0Fm8rccWZL34Jy-xS_0As_JEVHN1223aE7VHn9H3eg1I54q14MQvmIRiRbAU-uolnwDLtpU1gsHwWzGxnekb4pLMwZyLOnHhz8F5VXloJ9b22qvKE
Choosing a target type.  

Step 4: Next, enter a name for your Target group and select the protocol. Here we are using TCP with port 80. There are other protocols as well. Below are some of them: 

  • If the listener protocol is TCP, choose TCP or TCP_UDP. 
  • If the listener protocol is TLS, select TCP or TLS. 
  • If the listener protocol is UDP, select UDP or TCP_UDP. 
  • If the listener protocol is TCP_UDP, choose TCP_UDP. 

Step 5: Select the Virtual Private Cloud you want to use. Then enable Health check protocol like TCP, and click on Next.

https://lh5.googleusercontent.com/92UCvmySqw5wBzv1FVEoOqvJ0ueVZrShuNSiyO-9tWzlbMLqJBb1xNmqAt9wVbRb1Vm0lZNjr5ZROYLO3f5xX7k_3L8F-U8isfbjEbfYdKXksXiOwg9gC9e5GONJEWSRHpQhfsdh
Choosing the Virtual Private Cloud and Protocol version. 

Step 6: Now, you can register the Target as shown below. 

https://lh4.googleusercontent.com/QrUvb4OScGSQru64IsrZP9XFH487lE0dv_T6WVNvQljZIHxX7CIrkvNuTuqviafbE3qWx911obR4Kxxv8xxgEhjb1Xc_Reygkwy08Cy0N8h4rDziiYuOyB5TarpmUDbhpR-GL4YH
Registering the target in Step 6

Step 7: Since we have selected an IP as the target, you must enter an IP from your VPC and click on create. The Target Group will be listed below. 

https://lh5.googleusercontent.com/a5EsYPWRCHxmF08pQ-2Jo_h_Duo5Ihrb8GEAlMJot3SMFRgh0TZ6ianzZ7xkB7eFPLZUBZDnp16prGeRNy00cZD9wagpJjXI-mbeR_3rPrUzgpFQFBhGKWq5x1dIJx4D7WMSMGUz
Choosing the IP from the VPC

Now you have created a network load balancer. It’s time to configure it and the listener! 

Configuring A Network Load Balancer And A Listener 

These are the steps to configure a network load balancer and its listener. 

Step 1: Log in to the console (https://console.aws.amazon.com/ec2/). 

Step 2: In the navigation pane, under Load Balancing, choose Load Balancers. 

https://lh6.googleusercontent.com/VkoHi4r003RsfvtKN2Hq5Xj1RwDqmFQQoZNkRoYv3YQ6lF4tOxUkxVmLGP0oKODBrH9MY7NiP0dathFgU0cSAymlF4wlRvR4opUckx9-HYVFocl7hL4Xaz6l5zV1PUFoRJCcoxyz
Configuring load balancers. 

Step 3: Click on create Load balancer and select load balancer type. As we are working on a Network Load Balancer, select it and hit Create.

https://lh6.googleusercontent.com/W2XIpw7rEkgmHB8rx4Dk8MfYWS0iz5PZ8ZbGbZ2cXmTlrwWTdA3Koot1pSmMibr-UhfR_ivmqrztWCZglP0Nw718yAfjSVzy8NaxZ-pM7QnP1hYhCcJeKynNhEcgmmE76tWEvLjI
Step 3 Choosing Network Load Balancer.

Step 4: Enter the Network Load Balancer name. Select the scheme, whether it’s internal or Internet-facing. Here we are selecting Internal as the project requires it. 

https://lh6.googleusercontent.com/P-njBeDzMGu9d58Irdg9U8A78Hh75s6TAPP1xD2qsZmK7S8lHgzRICOrC0nvrCuvpfJdo_9I5bSZ3Pqf8WfB_k7RtE3pGOlTpCF8h-nISUp4c2zbL1cMJF_RRKU6R24YjV-EQiJz
Step 4 Choose Internal Scheme.

Step 5: The next stage is network mapping. So select the VPC and the Availablity zone as the NLB is internal. Select subnets that are not public-facing.

https://lh4.googleusercontent.com/_0h2Sgo784NJdl8PvcD2wV-1_JQ6CZOE3Fwl5FFHghL4vsarlcNQXfB3v7OOFlOG5ehv_QBhWG331x1HEvOJeONBP_6TcqHiBDuOFpRxIS8kqtbO-j5yXvk31LzZfL1kbeLLj1v1
Step 5 Choosing those subnets that are not public-facing. 

Step 6: The last step is to configure the listeners and routing. Select the protocol and the port followed by the Target group. 

https://lh5.googleusercontent.com/4M8qRxjOMPbmHDi2VBAPeSOJXo6ZmTPrkoCG7F1A9a_bOvbkaVf3-E-YT7IXhBSSPEDAp7CuZyhDhd6Faj6N6m6Bbfb46bsoJTJOjkGmoqUxhejXrzG9yMwHQ6ipk_TwF-azO9YY
Select the protocol and port.

Step 7: Click on create. Provisioning may take some seconds. 

We have completed setting up the Network Load Balancer in AWS!

Now let’s look into how to set up the Application Load Balancer. 

What is an Application Load Balancer? 

An Application Load Balancer functions at the Application layer of the Open Systems Interconnection (OSI) model. 

After the Application load balancer receives a request, it evaluates the listener rules in priority order to determine which rule to apply. Then it selects a target from the target group for the rule action. 

How to Create Application Load Balancer? 

Here’s how to create an application load balancer. 

Step 1: Log in to the console (https://console.aws.amazon.com/ec2/

Step 2: In the left navigation panel, under Load Balancing, select Load balancers. Then, choose Application Load Balancer.

https://lh4.googleusercontent.com/EaZ89ECfnIdxJfyASnMZ2JZhdqXkRESDSCeVBsL_KMYi2wb8sbmkVeMdRMyDH_p6jb-s7csju-y6jWYEcfeCwLM_PdZN-kYuGsZQQ4fXcntbU4tNeAfp_8MnTxo47cNinV5fApVd
Choose Application load balancer.

Step 3: Now, you can start with basic configuration by setting a name for your Application Load Balancer, selecting whether it is internet facing or internal, and the IP address type. 

https://lh3.googleusercontent.com/3ygtvkSGXHgYzNqZmn0gW2sHe9o3pA0MZRRUrEbUEm9CHQeAJmq25F8_x_V3QP-YnWlMUkPftz9lWeRcCFgwTOLBq5clmHP-Jgaz_w4ztr7KztgA7iPbQbUXyQGE4OFYBNsA1vUO
Select whether internet-facing or internal.

Here, we are using the internet-facing scheme as we want the ALB to connect to the internet. 

Step 4: Next is to set up the Listeners. A listener is a process that checks for connection requests using the protocol and port that you configured. 

https://lh3.googleusercontent.com/uObvl5UHq7CVEm15dtrRVUS255MQNFyEswZ1APT2rp8TWSUli-EPI9aO1H3CLgMVEscfC5oOdlcoJ87MboOS_DJvJru0VJyIneIbc2QLZ5BGClhgcswPzwYA8xa5vcZtfdJKxo-P
Setting up a listener

Step 5: Set up an Available Zone for your ALB, including selecting your VPC, Availability zone, and subnets. 

https://lh4.googleusercontent.com/MaXnQl_IgJ1ZXRnUJh2vxOL4vOL5_OPzD-1PloDtsh5SWxKmzXHi1lYtfY9VaeHoabILZJuSOabGJPNumVWKr4rV8L-uhgZAdY26Djd7cpLpmds_ndlx5kxiQoQTUD8iB45iirXe
Setting up Availability Zones. 

Step 6: After that, you will go through the Configure Security Settings and set the security group you should maintain to add more security for your ALB.

Step 7: Now, let’s set up a Target group for your ALB. This is almost the same as what did for NLB previously. 

https://lh4.googleusercontent.com/a-0SjJHMv3dCIPD583AK0VVPAxEg0Pj9zAgICk6XV03yp80t9EKiL7BoUKEU3Nuy4buPphOfiONd87k4X9nStTRM___c0lkWub-bjP-VdMi6WF5UoD8EnhQB9DXekJlVrEyMm-5K
Setting up the target group 

Step 8: Here, you have to mention the name of your Target Group. Select the Target type. We have 3 options—Set Instance as Target, IP, and Lamba. We are using an instance here. 

Step 9: Set up the protocol, port, and protocol version. 

Step 10: Another essential part of this Application Load Balancer is a Health Check. For Health checks, keep the default health check settings, or you can change the path and protocol according to your application. 

Step 11: The last part of the configuration is configuring targets for the target group. To register targets by instance ID, follow these steps.

Step 10: For Instances, select one or more instances. Enter the instance listener port, and then choose to Add to register. Next is to create. On the Review page, choose to Create.  After the load balancer is configured, choose Close.

We have successfully set up the Application Load Balancer!

Wrapping Up

That was all about how to create a Network and Application Load Balancer in AWS. These can handle several workloads and scale millions of requests in one second. Therefore, they are pretty helpful for those applications or websites that have a lot of visitors. 

At SysAlly, we experiment with Cloud and the most useful information is passed on to the world as blogs. Signup for the updates.

Until later, here’s SysAlly signing off!

Get new insights right to your inbox

How can our experts help you?

Schedule your consultation

You may also like

  • By admin
  • in DevOps

Agile vs DevOps: What’s the difference

  • Nov 18, 2022 .
  • 9 min min
Read More
  • By admin
  • in DevOps

DevOps as a Service: All You Should Know

  • Aug 9, 2022 .
  • 9 min min
Read More
  • By admin
  • in Containerization

Containerization VS Virtualization: Understanding the Differences

  • Aug 4, 2022 .
  • 8 min min
Read More

Be in the know

Techno tips served hot! Subscribe now and stay atop.