Ec2 part2
Class 46th AWS EC2 June 16th
Load Balancer
Types of elastic load balancer
Target groups
Practical
Launch templates
Auto scaling 7 types of scaling
Auto scaling groups
Automatic scaling policies
Practical
What is the ELB?
- Elastic load balancing automatically distributes incoming
application traffic across multiple targets, such as amazon Ec2
instances, containers, IP addresses , lambda functions, and virtual appliances
- It can handle the varying load of your application traffic
in a single availability zone or across multiple
Users -->LoadBalancer-->Targetgroups-(round robin)-> Multiple Webappl Instances -->database
We have configured mapped domain to loadbalancer endpoint
Elastic Load balancing types:
Application load balancer :Best for:websites,web apps, and APIs(Http/Https)
Understands URL paths and headers -can route based on /login, /image ,etc
Smart choice for modern web apps or micro service
Network load balancer
Best for: High-spees and real-time apps(TCP,UDP)
Very fast handles millions for request per second
Use when speed and high performance are critical,like game servers or financial apps
Gateway load balancer:
Best for :sending traffic to security appliances like
firewalls,intrusion detection system(IDS), and traffic inspection tools.
Forwards traffic without modifying it,so security tools can
inspect the full,original packets.
Use when you need to inspect or filter traffic before it
reaches you applications like in secure VPC architectures or centralized
firewall setups .
Classic load balancer: not used
Practical:
All our instances private subnet ,our load balance is public subnet
Step1: Create three instance using Public subnet ,while creating instance add below code Advance details User data
#!/bin/bash
# STEP1 -updates
sudo yum update -y
# STEP2 -Begin Configuration
sudo yum install -y httpd
sudo systemctl start httpd
sudo systemctl enable httpd
# STEP3 Custom web page
echo "<h1>Welcome to CCIT Server 1 </h1>" >>/var/www/html/index.html
change last line remaining two servers For Server2 Second instance and Server3 for third instance
echo "<h1>Welcome to CCIT Server 2 </h1>" >>/var/www/html/index.html
echo "<h1>Welcome to CCIT Server 3 </h1>" >>/var/www/html/index.html
Step2:Three instances created ,Ec2-Instance1,Ec2-Instance2,Ec2-Instance3
Step3:Instance public ip able to access webpage server1,server2,server3 three tabs Step4:Need to create target group attach the instances to target group
Ec2>Target groups >create target groups ,Select first option instance given name target group
Target group name: CCIT-TG
Health checks :Here below User access the webpage, it will hit the load balancer distributed the traffice equally all webservers.
Advanced health check settings: default setup load balancer the webserver http port 80, every 5 seconds
and it will check 2 time, every 5 seconds interval consequently check server health check ,Success code is 200,Click Next
Click Including as pending below and then Click create target group
It is take some time come health status unused to used in target group , it was dependency with load balancer, so need create load balancer
Step5: Creating load balancer
Ec2>Load balancer >Choose Load balancer types >Application Load Balancer
Given any name ccit-loadbalance, All your instance should be in public choose your subnet public
Choose select target group: here http request 80 will go target group, target group based on health check it will go the request. then
click Create load balancer, it will take some time to active
Load balancer is now active
And target groups are now healthy, if any unhealthy instance we can create auto scale, it will create automatically when one instance has issues.
Step6: take the dns name from the load balancer end point http://ccit-loadbalance-1595733045.eu-west-2.elb.amazonaws.com/
After refresh multiple time same dns name ,the load is divided equally three server automatically
Step7:If you want, you can set these into route 53, How to buy the domain go daddy.. plat form and register the domain, for you domain add the record endpoint loadbalancer,it will give unique http: name.If you want https:// we have once concept ASM certificate in aws it will cover there.
Buying Domain in Go daddy
https://vakatisubbu.xyz/ Successfully brought the domain
Step8: Please the endpoint url from the loadbalancer step5 active loadbalancer, these dns is http://
DNSName:
ccit-loadbalancer-1607206506.eu-west-2.elb.amazonaws.com
Route53
Route 53 >Hosted zones Create host zone ,give you domain name which was purchased in godaddy click create hosted zone
Created successful Hosted zone for the domain
Here click create record
Click create record
Created record successfully.
We have create just domain today it will take 48 hour to complete, as of now, only came domain default page
ASM certificate
Step1:
Step2: give you domain name ,click request
Step3:Click Create record route 53Step4:
one record is adding in the hosted zone

Step5: After Pending validation success ,you got one SSL certificate
Loader Balance Completed.
Step8: Delete the load balancer deleted, plan to create autoscaling
Auto Scaling
Aws auto scaling monitors your applications and
automatically adjusts capacity to maintain steady, predictable performance at
the lowest possible cost.
Using AWS auto scaling, it’s easy to setup application
scaling for multiple resources across multiple services in minutes.
Vertical: Able to increase the capacity of the instance called vertical, no down time required.
Horizontal scaling :Able increase the instances not capacity of the instance is called Horizonal scaling,
down time required.
Existing Target group Health checks success code 200,2 consecutive check unhealth means the instance is unhealthy ,which our autoscale trigger create one instance automatically.
Delete the existing Target group, Terminate three instance, We will create instance you launch template.
Step1:Create Launch Template
EC2>Launch template >create launch template given any name ccit-launchtemplate,
here im not setting network, plan to setup in autoscaling group
User data add you http script code click create launch template
Created templated, below showing default version 1,latest version 1, if you do any change on launch template again new version will create not replaced existing version.
Step2: Create Autoscaling group
Ec2>Auto scaling group >Create Auto scaling group
No comments:
Post a Comment