top of page
  • Writer's pictureElite Cloud

How to create Application Load Balancer for EC2 instances

Application Load Balancer (ALBs) are critical in managing the traffic to your web applications deployed on AWS. By efficiently distributing incoming application traffic across multiple targets, such as Amazon EC2 instances. ALBs enhance your applications availability and fault tolerance.


Benefits of Using an Application Load Balancer with EC2 Instances

1. Improved Fault Tolerance: By continuously checking the health of linked EC2 instances. ALBs can redirect traffic away from failed instances. Thus minimizing downtime and ensuring a seamless user experience.


2. Scalability: ALBs automatically adjust to changes in incoming application traffic. Therefore making it easier for applications to scale up or down without manual intervention.


3. Enhanced Security: Application Load Balancers offer robust security features such as built-in SSL/TLS decryption. Which enables them to serve as the first line of defense against cyber threats.


4. Operational Efficiency: You can also the management of user sessions by enabling sticky sessions.


5. Advanced Routing Capabilities: Furthermore, ALBs support content-based routing. Thus allowing you to route traffic based on the content of the request, including URLs, headers, and HTTP methods.


Prerequisites for Creating an Application Load Balancer

Before you begin the process of creating an Application Load Balancer for your EC2 instances. It’s important to ensure that you have the following prerequisites in place:


1. AWS Account Setup: You must have an active AWS account. If you do not have one. You can sign up at the AWS website.


2. Existing EC2 Instances: Ensure that you have two or more EC2 instances running. These instances will be the targets for your load balancer.


3. Required IAM Permissions: Also, ensure that your AWS user account has the necessary permissions to create and manage load balancers.


Step-by-Step Guide to Creating an Application Load Balancer

Once you have the prerequisites in place. You can follow these steps to create an Application Load Balancer for your EC2 instances:


Step 1: Access the EC2 Management Console

Sign in to your AWS Console and navigate to the EC2 dashboard. This is your central hub for all operations related to EC2.


Step 2: Navigate to the Load Balancers Section

Then within the EC2 dashboard, find the “Load Balancers” section under the “Load Balancing” menu. From there click on “Create load balancer”.


 Creating an Application Load Balancer

From there select application load balancer.


Selecting Load Balancer type

Step 3: Configure the Load Balancer

Here give the Load balancer name. And also set the following options.


 Configuring the Load Balancer

Select at least two availability zones from there.


 Configuring the Load Balancer

Then, select the security group that has the necessary ports allowed. 


 Configuring the Load Balancer

Now click a target group by clicking on the “Create target group” (open it in a new tab) link.


 Configuring the Load Balancer

Here select the “Target type” to instances.


 Configuring the Load Balancer

And also use a Target Group name.


Selecting Target Group

Keep everything else default and then click on next.


After that, select the EC2 instances that you want to connect with the load balancer. Then click on “Include as pending below”.


Adding instances to target group

Now click on “Create target group”.


Creating Target Group

Finally, get back to the ALB configuration, refresh the target group, and select the newly created target group.


Adding target group

Everything looks good, you can include WAF and Global Accelerator. As this is a simple demo. I will be skipping this.


Skipping AWS WAF, And AWS Global Accelerator

Now, proceed to do a final review, and then click on ‘Create load balancer’.


Verifying the Load Balancer

The load balancer will take some time to get ready. It will change the status from “Provisioning” to “Active”.


Load Balancer Setup complete

Once the status is shown “Active”, copy the “DNS name”.


Load Balancer Setup complete

Navigate to the browser and paste the URL. Then, try refreshing the URL. As you do so, you will see it’s changing the instances each time you refresh.


Testing Load Balancer

Testing Load Balancer

You can now use your domain in Route 53 and create an alias for this ALB. As a result, your users will not notice they are switching servers. But you must make sure that your application is capable of utilizing a Load Balancer.


Cleaning Up

Once you are done practicing, you should remove all the resources to avoid any charges.


Navigate to the “Load Balancer” Dashboard, and then select the load balancer. Then from “Actions” select “Delete load balancer”.


Cleaning UP Load Balancer

Follow up with the confirmation. After that, navigate to the Target Group, and select the target group. From there click on “Actions” and delete. 


Cleaning UP Load Balancer

Next, you can either delete the EC2 instances that you created or stop them.


Additional Resources

5 views0 comments

Comments


Unleash Your Business Potential with Elite Cloud | Boost Efficiency & Scalability.

Get in Touch

+886 2-26575580

bottom of page