Creating an Application Load Balancer from AWS CLI

Lab Details

  1. This lab walks you through the steps to create an Application Load Balancer from AWS CLI.

  2. You will practice using AWS EC2 and AWS Load Balancers.

  3. Duration: 1 hour

  4. AWS Region: US East (N. Virginia) us-east-1


AWS Elastic Load Balancer

  1. Elastic Load Balancer is used to manage load balancing between multiple EC2 instances across in multiple availability zones on AWS.

  2. It distributes the load across specified targets.

  3. It enables us to have increased availability of the application in multiple availability zones.

  4. It’s a fully managed service that can distribute incoming traffic to AWS resources in different availability zones.

  5. It monitors the health of the targets and routes traffic accordingly to the healthy targets.

  6. The load balancer can accept incoming traffic by configuring listeners with a protocol and port number.

  7. The target group can be configured with a protocol and port number to route the traffic to that particular target only if the target's health is healthy.

  8. Elastic load balancer supports scaling, which can be done automatically as the traffic to the application changes.

  9. Modification of targets from the load balancer can be done without disturbing the other requests at any point in time.

Types of Load Balancers

  1. AWS Elastic Load balancers support 3 types of load balancing, namely:

    • Classic Load Balancer: Routing and load balancing decisions are taken at the transport layer or the application layer. It supports EC2-classic and VPC.

    • Network Load Balancer: Routing and load balancing decisions is taken at the transport layer. It's used for applications that need high availability and performance.

    • Application Load Balancer: Routing and load balancing decisions is taken at the application layer.

Application Load Balancer

  1. Application Load Balancer is used for applications that need advanced functionality and application-level support.

  2. It works at the application layer which is layer 7 in the OSI model.

  3. It supports protocols such as HTTP and HTTPS only.

  4. The application load balancer has target groups that will have registered targets such as EC2 instances.

  5. The application load balancer routes the traffic to the specific target based on rules, even though the contents of the target instances are different.

  6. The application load balancer acts as a one-point contact, which manages the incoming traffic.

  7. The connection requests to the instances are managed by the load balancer with the help of listeners.

  8. The listeners are configured with protocol and port numbers and the listeners are also configured with rules to route the traffic to the registered targets.

  9. The listener should have a default rule so that the incoming requests are routed there by default. Other rules can be configured with suitable actions for the conditions and priority.

  10. When the incoming request matches the condition set in the listener rule, the load balancer routes the request to that particular target group.

  11. The target group routes the request to the registered target’s EC2 instance using the protocol and port number.

  12. A target can be registered with multiple target groups and health check configurations can be done separately.

  13. Health checks are done based on the listener rule for all the targets.

  14. Once the load balancer receives the request, it checks the listener rules based on its priority order and decides which rule to apply.

  15. According to the rule it finds, it selects the targets from the target group.

  16. Listener rules can be also configured to route traffic to the target groups based on the content of the application traffic.

Architecture Diagram


Task Details

  1. Log into AWS Management Console.

  2. Creating EC2 Instance.

  3. Creating another EC2 Instance.

  4. Creating an Application Load Balancer in AWS CLI.

  5. Creating a Load Balancer.

  6. Creating 2 Target Groups.

  7. Register the Targets with their Respective Target groups.

  8. Creating Listener Default Rules.

  9. Creating Listeners for other rules.

  10. Verifying the health of the Target Groups.

  11. Verifying the Load balancer rules by accessing the DNS.

  12. Validation of the lab.

  13. Deleting AWS Resources.