ELB
CLB
ALB
Work on OSI layer 7 HTTP
Route routing
Hostname routing
Query string routing
Target Groups
EC2 instances(can also use with ASGs)
ECS
Lambda functions
Gets a fix hostname
App server can’t see the ip of the client,
Ip inserted through X-forwarded ip and X-forwarded port
Load balancer talk to the EC2 instance privately
NLB
Layer 4 (works with UDP, TCP)
High performance
Ultra low latency
Has one static IP per AZ, support Assigning Elastic IP
Used for extreme performance
Target Groups
EC2 instances
Private Ips (hard coded)
Load balancer (LB will get static ips)
GWLB
To analyze the traffic by sending third party security group which is inside target group
and send the traffic to the GWLB and the GWLB send that traffic to the application server
Operates on Layer 3 IP packets
Combines 2 functions - transparent network gateway(single entry/exit), loadbalancer
GENEVE protocol on port 6081 (GWLB)
Sticky Sessions
Application based cookie
Custom cookie
- Generated by the target
- Custom attributes required by the application
- Cookie must be specified individually for each target group
- AWSALB,AWSALBAPP,AWSALBTG(can’t be used)
Application Cookie
- Generated by the load balancer
- Name is AWSALBAPP
Duration based cookies
- Generated by the load balancer
- Name AWSALB,AWSELB(for CLB)
Cross Load balancing
Distribute traffics evenly even in the different zones
Application Load Balancer
- Enabled by default(can be disabled on the target group level)
- No charges for inter AZ data
NLB & GWLB
- Disabled by default
- Pay charges if inter AZ data is enabled
Classic Load Balancer
- Disabled by default
- No charges for inter AZ if enabled
Sever Name Indication (SNI)
Can use multiple SSL certificates for various domains
each SSL will be correctly used for the target domain
Only works for ALB, NLB(Newer LB) and cloudfront
Not working for CLB (older gen)
CLB-only one SSL can be used, must use multiple SSL for multiple hostname with multiple SSL certificates
ALB, NLB - can be used with multiple listeners and SSL. Use with (SNI)
Connection Draining
Connection Draining for CLB
Deregistration Delay for ALB,NLB
Time to complete inflight request when the instance is unhealthy or deregistering
Stop sending new request to that
Can be disabled by setting value 0
Can set between 1-3600s
Set low values if the request process time is short
ASG
Minimum capacity - the minimum capacity of instances
Desired Capacity - the capacity of instances that you want
Maximum Capacity - the maximum capacity that you want
Launch Template
- AMI + instance type
- EC2 users data
- EBS volume
- IAM
- Security Group
- SSH pair
- Network Subnet info
- LB info
Scaling Policies
Can be scaled using Cloudwatch metrics
- Average cpu or custom metric
- Can create scale in policies
- Can create scale out policies
Dynamic Scaling
Target Tracking
- Scale to cpu usage stay around 40%
Step Scaling(for example)
- Scale up 2 if cpu usage is 40%
- Scale down 1 if cpu usage is 30%
Schedule scaling
- Continuously forecast load and schedule scaling ahead
Good metrics to scale on
CPU utilization
Request count per target
Average Network in and out
Any custom metrics push to cloud watch
300s cooldown effect
during cooldown period ASG will no launch or terminate new instances