Load Balancers in AWS
Setup for LoadBalancing
- Lets create an 2 AMI for 2 websites in it
- Setup steps for Website 1 – boxer
sudo apt update
sudo apt install nginx unzip -y
cd /tmp
wget https://www.free-css.com/assets/files/free-css-templates/download/page296/oxer.zip
unzip oxer.zip
sudo mv oxer-html /var/www/html/boxer

* Setup for Website-2 – Gym
sudo apt update
sudo apt install nginx unzip -y
cd /tmp
wget https://www.free-css.com/assets/files/free-css-templates/download/page296/neogym.zip
unzip neogym.zip
sudo mv /var/www/html/neogym-html/ /var/www/html/
sudo mv /var/www/html/neogym-html/ /var/www/html/gym

* For AMI creation steps watch classroom recording
AWS Load Balancers
- AWS has 3 types of load Balancerss
- Network Load Balancer: This is layer 4 load balancer
- Application Load Balancer: This is Layer 7 LB
- Gateway LB
- AWS has a classic load Balancer which supports both layer 4 and Layer 7 (old generation) and is not recommended anymore.
- Our focus will be on ALB and NLB
- LB’s can be private (within vpc) or public (from internet)
- LB will forward the request to different zones via subnets
- LB will have a security group
- Listeners and routing is about configuring rules
- Target group represents the instances where the traffic has to be forwarded. Target group one or more instances in different zones
Layer 4 LB with boxer website in our vpc
- Lets create a vpc with minimum 2 public subnets in 2 AZs

- Create a security group to open tcp 80 port

- Now create two ec2 instances in 2 subnets (autoscaling group)
- Make this two ec2 instances as a target group
- Now create a Layer 4 LB (NLB) with
- rules
- 80 of LB will be forwared to 80 of Target group on TCP

- 80 of LB will be forwared to 80 of Target group on TCP
- rules
Layer 7 LB
- Lets create a vpc with minimum 2 public subnets in 2 AZs

- Create a security group to open tcp 80 port

- Now create two ec2 instances in 2 subnets (autoscaling group) using boxer ami
- Now create two ec2 instances in 2 subnets using gym ami

- Now create a gym target group and boxer target group
-
Now configure lister with a rule such that if the url has a path
gymforward to gym target group and if path hasboxerforward to boxer target group

-
Addons for Applciation Load Balancer
- WAF
- Global Accelarators
