🌐 Setting Up a Network Load Balancer (NLB) on AWS

Learn how to set up a high-performance Network Load Balancer on AWS with detailed step-by-step instructions.


🚀 Step 1: Launch EC2 Instances

The EC2 instances are servers that host your application, and the NLB will distribute incoming traffic to these instances.

  1. 🔍 Navigate to EC2 Dashboard:
    • Sign in to your AWS account and search for EC2 in the console search bar.
  2. 💻 Launch Instances:
    • Click Launch Instances.
    • Select an Amazon Machine Image (AMI), such as Amazon Linux 2 AMI.
    • Choose an Instance Type (e.g., t2.micro for testing).
    • Click Next: Configure Instance Details.
  3. ⚙️ Configure Instance Details:
    • Ensure instances are in the same VPC and select different Availability Zones for high availability.
    • Enable Auto-assign Public IP for internet access.
  4. 🏷️ Add Tags (Optional):
    • Add tags like Name=MyInstance1 to identify resources.
  5. 🔒 Configure Security Group:
    • Create a new or use an existing security group.
    • Add inbound rules to allow traffic (e.g., HTTP, TCP).
  6. 🔑 Launch and Access Key Pair:
    • Choose an existing or create a new key pair for SSH access.
    • Launch the instances and wait for them to reach Running status.

🛠️ Step 2: Create a Target Group

A Target Group is a logical grouping of your instances that the NLB will direct traffic to.

  1. 🔍 Navigate to Target Groups:
    • Go to the EC2 Dashboard and find Target Groups under Load Balancing.
  2. 📋 Create Target Group:
    • Click Create target group.
    • Choose Instances as the target type and configure settings like protocol (TCP) and port (e.g., 80).
  3. 💉 Configure Health Checks:
    • Set protocol to TCP and configure thresholds and timeouts.
  4. ✅ Register Targets (Instances):
    • Select and include the instances in the target group.

🔄 Step 3: Create a Network Load Balancer

The Network Load Balancer distributes traffic to your instances based on Layer 4 protocols like TCP.

  1. 🔍 Navigate to Load Balancers:
    • Under Load Balancing, select Load Balancers.
  2. ⚙️ Configure NLB Basic Settings:
    • Set up a name, scheme (e.g., Internet-facing), and IP address type (e.g., IPv4).
  3. 📜 Configure Listeners and Routing:
    • Define the listener port and protocol, and associate the target group created earlier.
  4. 🌍 Availability Zones and Subnets:
    • Select subnets across multiple availability zones for high availability.

🔐 Step 4: Configure Security Groups

Security groups act as firewalls for your EC2 instances, controlling traffic flow.

  1. 🔒 Allow Traffic from the NLB:
    • Edit security group inbound rules to allow traffic from the NLB’s IP range.

🔍 Step 5: Test the Load Balancer

  1. 🌐 Get DNS Name of NLB:
    • Find the DNS name of your NLB in the Load Balancers section.
  2. 📡 Test Traffic Routing:
    • Send requests to the DNS name via a web browser or curl.

📈 Step 6: Monitor and Manage the NLB

  1. 📊 Monitor with CloudWatch:
    • View metrics like HealthyHostCount and ActiveFlowCount.
  2. 🔄 Adjust Target Group Settings:
    • Add more instances or tweak health checks as needed.

🎉 Congratulations! You’ve successfully set up a Network Load Balancer on AWS. For advanced configurations, explore AWS documentation.

Related articles

Create and attach EBS volumes to instances.

Create and Attach EBS Volumes to Instances. When working with Amazon Web Services (AWS), Elastic Block Store (EBS) volumes...

Azure Monitor vs Log Analytics

Azure Monitor vs Log Analytics In the modern enterprise cloud landscape, a common business pain point for CTOs and...

Disk Storage in Azure

Disk Storage in Azure 🌟 Introduction Microsoft Azure Disk Storage is a high-performance block storage solution designed for Azure Virtual...

Cloud Based Services

Cloud Based Services Cloud computing has transformed the way organizations store, manage, and process data by leveraging remote servers...