This lab walks you through the steps to create an Application Load Balancer from AWS CLI
You will practice using AWS EC2 and AWS Load Balancers
Duration: 1 hour
AWS Region: US East (N. Virginia) us-east-1
Elastic Load Balancer is used to manage load balancing between multiple EC2 instances across in multiple availability zones on AWS
It distributes the load across specified targets
It enables us to have increased availability of the application in multiple availability zones
It’s a fully-managed service which can distribute incoming traffic to AWS resources in different availability zones
It monitors the health of the targets and it routes traffic accordingly to the healthy targets
The load balancer can accept incoming traffic by configuring listeners with a protocol and port number
The target group can be configured with a protocol and port number to route the traffic to that particular target only if the target health is healthy
Elastic load balancer supports Scaling, which can be done automatically as the traffic to the application changes.
Modification of targets from the load balancer can be done without disturbing the other requests at any point of time
Types of Load Balancers
AWS Elastic Load balancers supports 3 types of load balancing, namely:
Classic Load Balancer→ Routing and load balancing decisions taken at the Transport layer or application. It supports EC2-classic and VPC.
Network Load Balancer→ Routing and load balancing decisions taken at Transport layer. It's used for applications which need ultra high performance
Application Load Balancer
Application Load Balancer is used for applications which need advanced functionality and application level support
It works at application layer which is layer 7 in the OSI model
It supports protocols such as HTTP and HTTPS only
The application load balancer has target groups which will have registered targets such as EC2 instances
The application load balancer routes the traffic to the specific target based on rules, even though the contents of the target instances are different
The application load balancer acts as a one-point contact, which manages the incoming traffic
The connection requests to the instances are managed by the load balancer with the help of listeners
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
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
When the incoming request matches the condition set in the listener rule, the load balancer routes the request to that particular target group
The target group routes the request to the registered target’s EC2 instance using the protocol and port number
A target can be registered with multiple target group and health check configurations can be done separately
Health checks are done based on the listener rule for all the targets
Once the load balancer receives the request, it checks the listener rules based on its priority order and decides which rule to apply
According to the rule it finds, it selects the targets from the target group
Listener rules can be also configured to route traffic to the target groups based on the content of the application traffic
Go to the AWS console and manually Create 2 EC2 instances in the default VPC but in different availability zones.
Open the AWS console, go to the EC2 dashboard and SSH into the already-available EC2 instance with its public IP (an instance will be available initially at the time of your lab launch)
Via SSH using the AWS CLI command, configure the instance in the US- N.Virginia region (us-east-1)
Using AWS CLI commands, create an Application Load Balancer
Using AWS CLI commands, create 2 target groups in the default VPC, which routes the traffic based on the application traffic
Using AWS CLI commands, register each EC2 instance with each Target group
Using AWS CLI commands, create a default listener rule
Using AWS CLI commands, create another 2 rules, each rule to route the traffic to a separate target group based on paths
Using AWS CLI commands, verify the health of the targets