Day 41: Setting up an Application Load Balancer with AWS EC2 ๐Ÿš€ โ˜ - 90DaysOfDevOps

Day 41: Setting up an Application Load Balancer with AWS EC2 ๐Ÿš€ โ˜ - 90DaysOfDevOps

ยท

3 min read

What is Load Balancing?

Load balancing is the distribution of workloads across multiple servers to ensure consistent and optimal resource utilization. It is an essential aspect of any large-scale and scalable computing system, as it helps you to improve the reliability and performance of your applications.

LoadBalancer

Elastic Load Balancing:

Elastic Load Balancing (ELB) is a service provided by Amazon Web Services (AWS) that automatically distributes incoming traffic across multiple EC2 instances. ELB provides three types of load balancers:

  1. Application Load Balancer (ALB) - operates at layer 7 of the OSI model and is ideal for applications that require advanced routing and microservices.
  1. Network Load Balancer (NLB) - operates at layer 4 of the OSI model and is ideal for applications that require high throughput and low latency.
  1. Classic Load Balancer (CLB) - operates at layer 4 of the OSI model and is ideal for applications that require basic load balancing features.

๐ŸŽฏ Today's Tasks:

Task 1:

  • launch 2 EC2 instances with an Ubuntu AMI and use User Data to install the Apache Web Server.

  • Modify the index.html file to include your name so that when your Apache server is hosted, it will display your name also do it for 2nd instance which includes " TrainWithShubham Community is Super Awesome :) ".

User data for the First Instance -

#!/bin/bash
sudo apt-get update
sudo apt-get install -y apache2
echo "<html><body>My Name</body></html>" > /var/www/html/index.html

User data for the second Instance -

#!/bin/bash
sudo apt-get update
sudo apt-get install -y apache2
echo "<html><body>TrainWithShubham Community is Super Awesome :) </body></html>" > /var/www/html/index.html
  • Copy the public IP address of your EC2 instances.

  • Open a web browser and paste the public IP address into the address bar.

Task 2:

  • Create an Application Load Balancer (ALB) in EC2 using the AWS Management Console.

    1. Go to the AWS Management Console and navigate to the EC2 service.

    2. Click on "Load Balancers" in the left-hand menu.

    3. Click the "Create Load Balancer" button.

    4. Select Application load balancer.

Here, we need to select the listeners (Click on Create target group and select the instances) -

Target group created and selected -

LB is created -

  • Verify that the ALB is working properly by checking the health status of the target instances and testing the load-balancing capabilities.

Health check -

Testing LB -

  1. Go to LB details and find the DNS name.

  2. Open a web browser and enter the ALB's DNS name or IP address.

  3. Refresh the page multiple times to verify that the load balancer is distributing the requests evenly to the registered instances.

Hope you enjoyed :)

Thank you :)

ย