Setting up an Application Load Balancer with AWS EC2

2 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.

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:

Read more from here

  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.

Task 1: Launch 2 EC2 instances with an Ubuntu AMI and use User Data to install the Apache Web Server.

  1. Log into your AWS Console and go to the EC2 dashboard.

  2. Click on create a launch template

  3. name the launch template and add user data to install apache server.

  4. Select ubuntu machine and select free tier instance t2.micro

  5. add user data and click on launch template.

  6. Click on Lauch instace with existing Template.add 2 instance and click on launch instances.

  7. you can see it on instances.

  8. connect servers with SSH client in terminal.

    server1

    server2

Task 2:

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

  • Add EC2 instances which you launch in task-1 to the ALB as target groups.

  1. click on load balancer in the left navigation bar and click on create a load balancer.

  2. select on Application Load Balancer

  3. name the load balancer and ass target group. if there are no target group click on create a target group

    and create it.

  4. click on create a Load Balancer.

    Done!!

Happy Learning!!