Create Network Loadbalancer In AWS

What Is Network Loadbalancer?

Network load balancer is used to distribute the traffic across the registered EC2 instances.

It has the ability to handle millions of requests per second.

It works on the Layer 4 (Network Layer) of the OSI model.

It’s the single and primary point of contact for the requests from the clients.A Load balancer is used to distribute the traffic coming from the clients across multiple targets which ensures the high availability of the applications.

Components Of Network Load Balancer:

TARGET GROUP:

We can register one or more targets in the target group and the targets be EC2 Instances.

The target group will take care of routing the traffic to the registered EC2 Instances based on the protocol and the port number configured.

And each target can be registered with multiple target groups.

We can configure a listener in the load balancer to check health of the targets on each target groups.

LISTENER:

Listeners are used to check for the requests from the clients based on the port and the protocol we configured.

We can add a rule in the listener and based on that the traffics are routed to the target instances.

And these rules works based on the rule number and of high priority.

Creating Network Loadbalancer

To create Network load balancer , Go to EC2 CONSOLE

under Load Balancing , Click Load Balancers

Click Create Load Balancer , You will asked to choose the type of loadbalancer you want

Select Network load balancer , Click Create

Step 1: Configure Loadbalancer

Under Basic configuration , We need to provide a name for the load balancer.

Under Schema , You choose choose the load balancer to act either public or private.

internal , If you want the network load balancer to communiicate within the VPC and to the private EC2 instances. Client will not be able to send the requests to the load balancer.

Select internet-facing , If you want to receive the traffic from the clients outside the VPC so that the network load balancer will route those traffic to the registered EC2 instances.

Next We have to configure listeners on the load balancer SO that it will accept the requests from the clients on the PORT and the PROCOTOL configured.

Basically , Listeners are used to check for the incoming requests using the protocol and the port configured.

Next We need to specify the availability zones so that the load balancer will route the traffic only the instances in these availability zones.

Static Public IP For Loadbalancer

Network load balancer has a feature of adding static public IP to it.

And You can add one Elastic IP per availability zone.

To do so , IF you choose the availability zone , By default AWS will assign an IP to the load balancer but it wont be static.

You should select , choose an Elastic IP to configure it.

Step 2: Configure Routing

Load balancer will route the traffic to the targets in the target groups using the port and the protocol we configure.

Next we need to configure health checks , So that the load balancer will perform health checks on the target instances and route traffic only to the healthy targets.

Step 3: Registering EC2 Instances

We have created a target group.Now we have to add the EC2 instance to the target groups.

Choose the instances and click Add to registered

You should see the lists of EC2 instances under Registered targets.

Choose Next: Review

Review the configurations of the network load balancer and click Create.

Step 4 : Testing Network Load Balancer

Once the load balancer is created.

Select the load balancer and click Target groups.

Choose targets and If the health check is configured properly , The instances should be in ready state.

if you see the instances are in initial state , It’s just getting registering with the target groups of the load balancer.

Once the instances becomes healthy.

To verify the load balancer , Click Load balancers and select the load balancer,

You should copy the DNS name of the Load balancer Under the description of Load balancer.

Paste the DNS name in the browser and you should see the default page of the application or web server.

Conclusion:

We have successfully created a network load balancer and configured target groups , registered targets and listeners.

Thanks for reading this article , Hope you find it helpful.

Please do check out my other publications.