Step-By-Step on Creating an Application Load Balancer (ALB)
Step-By-Step on Creating an Application Load Balancer (ALB) | By: Kurt Hummel

Step-By-Step on Creating an Application Load Balancer (ALB)

In Amazon Web Services (AWS), they've got this cool thing called a load balancer. It's like the traffic cop for your website or app. What it does is spread out all the incoming visitors across a bunch of servers or instances. Why? Well, the main deal is to make sure no single server gets bombarded with too much work. This way, your app stays available, deals with problems without breaking a sweat, and can easily grow as more folks start using it.

Here's why people dig using load balancers in AWS:

High Availability:?Ever worry about a server crashing and taking your whole app down with it? Load balancers got your back. They share the load among different servers, so if one decides to take a break, the others step up. This way, your app stays up and running, and downtime is just a distant nightmare.

Fault Tolerance:?Servers can be moody sometimes, right? If one decides to throw a fit, the load balancer is the cool friend who says, "No worries, I got this." It automatically sends traffic to the healthy servers, keeping your service going strong and minimizing any disruptions.

Scalability:?Imagine your app is throwing a party, and the guest list keeps growing. Load balancers help you handle the crowd by spreading the work among more servers. Add more servers to the mix, and the load balancer adjusts things so everyone gets a piece of the action without any server feeling overwhelmed.

Improved Performance:?Load balancers are like the DJs of traffic. They use fancy algorithms to decide which server gets the next visitor, making sure things run smoothly. It's like having a party planner who ensures everyone gets in without causing chaos, so your app responds quickly and impresses the crowd.

SSL Termination:?Load balancers even tackle the tricky task of decrypting secure connections (SSL/TLS). It's like having a buddy who takes care of the complicated stuff, freeing up your app servers to focus on their strengths. This makes your app more efficient and keeps your servers from feeling the pressure.

This step-by-step tutorial should help you create your own application load balancer in AWS if needed.

Create instances:?Click the orange Launch Instances button. Name it whatever you wish. I'll be naming mine ALB Instances Tutorial. On the right, below the Summary, we will put 2 for the number of instances we create. Under Application and OS Images, we'll select Amazon Linux, and the Free tier eligible Amazon Linux 2023 AMI. For the instance type, t2 micro (Free tier eligible). The Key pair is not needed for this tutorial, so we'll select Proceed without a key pair.

Create Instance
Key Pair

Security group:?I already have some security groups I could use, but this is a good opportunity to show you how to create them. I'm Allowing SSH traffic from Anywhere, and since I'm creating a dummy website, we'll allow HTTPS traffic from the internet. If I were to create a real security group, I would limit the IP addresses with access to the instances

Create security group

.Go ahead and click on the "Edit" button next to Network settings, and make sure to name the new Security group I'm naming mine, ALB-Tutorial.?

Configure storage: As you can see, AWS allows up to 30 GB to stay in the Free tier eligibility, but since this is a tutorial, we'll keep it at 8.

Add the static website code:?Click advanced details, scroll to the bottom, and in the box under "User data", paste your simple Hello World code. Now click Launch Instance.

Add static website code

Check out the website:?Copy the Public IPv4 address and paste it into your browser. It's live!

Static website

.

New Instances

Create a load balancer:?On the left-hand side, navigate to Load Balancers and click it. Click the orange Create load balancer button. We're creating an Application Load Balancer, so hit create for that type.

Create load balancer

  • Load balancer name: Tutorial-ALB

Internet-facing

  • Select Internet-facing because it is public.
  • Select IPV4
  • VPC seeing, we'll select Default VPC.
  • Mappings: We'll select every available zone.
  • Security groups: Select ALB-Tutorial.
  • Listeners and routing: Click on Create Target Group.
  • Click on Instances
  • Target group name: I'll name mine Tutorial.
  • Protocol, we'll select HTTP/Port 80.
  • Health checks, we'll leave as HTTP.
  • Click "Next".
  • A new window will open; select the available instances. (make sure they are selected)
  • Click "Include as pending below"
  • Click "Create target group"
  • Return to the previous window where you clicked "Create target group"
  • Select the target group you just created.
  • No other selections are needed. Scroll to the bottom and click "Create load balancer"
  • Return to the Load balancers page. You'll see that the load balancer you just created is provisioning; this will take 5-10 minutes.
  • Now that the state is active, copy it and paste it into your browser. Refresh it, and now you'll see it alternate between the two EC2 instances you created. If you were to terminate one of the instances, the other one would continue to work, which is a great example of what a load balancer does.

1st EC2: 172-31-41-183
2nd EC2: 172-31-33-250

I'm thrilled that you've taken the time to follow this step-by-step tutorial! Now, let's take a moment to appreciate the sheer awesomeness of load balancers and why they're absolute game-changers for a multitude of reasons.

#aws #loadbalancer #amazonwebservices #ec2 #ec2incstances #cybersecurity #devops

要查看或添加评论,请登录

Kurt Hummel的更多文章

社区洞察

其他会员也浏览了