#Day41:Setting up an Application Load Balancer with AWS EC2๐Ÿš€

#Day41:Setting up an Application Load Balancer with AWS EC2๐Ÿš€

ยท

4 min read

Title: Load Balancing Demystified! ๐ŸŒ

In the world of digital connectivity, ensuring smooth and uninterrupted user experiences is paramount. Imagine a scenario where thousands of users are trying to access a website simultaneously - handling this traffic efficiently is where Load Balancing comes into play! Let's take a cheerful journey through the basics of Load Balancing and explore the magic of Amazon Web Services' Elastic Load Balancing (ELB) with its three charming avatars: Application Load Balancer (ALB), Network Load Balancer (NLB), and Classic Load Balancer (CLB). โœจ

What is Load Balancing?

Load Balancing is like having a super-friendly traffic manager for your website or application. When numerous users knock on your digital door, a load balancer steps in to evenly distribute the incoming traffic among multiple servers. This smart balancing act ensures no server is overwhelmed, making sure everyone gets served quickly and efficiently! ๐ŸŽ‰

Elastic Load Balancing: Your Digital Fairy Godmother!

Amazon Web Services (AWS) offers a magical service called Elastic Load Balancing (ELB). It's like having a fairy godmother for your digital kingdom, ensuring everything runs smoothly. ELB comes in three delightful flavors:

1. Application Load Balancer (ALB) ๐ŸŒŸ

ALB is like a sophisticated maรฎtre d' in a high-end restaurant. It operates at the application layer of the OSI model, making intelligent decisions based on content. It's perfect for routing HTTP/HTTPS traffic and is a master at hosting multiple applications on a single domain.

2. Network Load Balancer (NLB) ๐Ÿ’ก

NLB is the tech-savvy guru of the ELB family. It operates at the transport layer (Layer 4) and can handle massive traffic loads with ease. If your applications demand high performance and low latency, NLB is your go-to option. It's ideal for TCP/UDP traffic.

3. Classic Load Balancer (CLB) ๐ŸŽฉ

CLB is the vintage charmer, versatile and reliable. It balances the load across multiple Amazon EC2 instances, ensuring your applications run seamlessly. While newer siblings like ALB and NLB have more features, CLB remains a solid choice for various applications.

Task 1: Launch EC2 Instances with Apache Web Server Installed

  1. Launch EC2 Instances:

    • Go to the AWS Management Console.

    • Navigate to EC2 and click on "Launch Instance."

    • Choose the Ubuntu AMI and follow the wizard to launch two instances.

    • In the Configure Instance Details section, paste the following User Data script:

#!/bin/bash
apt update
apt install -y apache2
echo "Your Name" > /var/www/html/index.html

Replace "Your Name" with your actual name for the first instance.

For the second instance, use the following User Data script:

#!/bin/bash
apt update
apt install -y apache2
echo "TrainWithShubham Community is Super Awesome :)" > /var/www/html/index.html
  • Complete the instance creation process.

  1. Copy Public IP Addresses:

    • Once instances are running, copy their public IP addresses from the AWS Management Console.
  2. Access Apache Web Server:

    • Open a web browser and paste the public IP addresses into the address bar for both instances. You should see webpages displaying your name and the specified message.

Task 2: Create Application Load Balancer (ALB) and Add Instances

  1. Create Application Load Balancer:

    • Go to the AWS Management Console.

    • Navigate to EC2 and click on "Load Balancers."

    • Click on "Create Load Balancer" and choose "Application Load Balancer."

    • Configure the ALB settings, including listeners and availability zones, as per your requirements.

  2. Add Instances to Target Groups:

    • While creating the ALB, create a new target group or use an existing one.

    • Add the EC2 instances created in Task 1 to the target group.

  3. Verify ALB and Test Load Balancing:

    • After ALB is created, go to the "Target Groups" section in the EC2 dashboard.

    • Check the health status of instances to ensure they are healthy and registered with the ALB.

    • Open a web browser and access the ALB's DNS name or public IP address. The requests should be distributed between the instances. Verify that the pages with your name and the specified message are displayed, confirming that the ALB is working correctly.

That's it! You have successfully completed Task 1 and Task 2, creating EC2 instances with Apache Web Server, modifying webpages, and setting up an Application Load Balancer to distribute traffic between the instances.

ย