Load Balancing & Scaling Flashcards
What is a load balancer?
A service that distributes incoming application traffic across multiple targets, such as EC2 instances, in multiple Availability Zones to increase the availability of your application.
How does a load balancer work?
By using one or more listeners. It checks for connection requests, then forwards the request based on your rules. A listener has a default rule and you can add more.
What are the features of a load balancer rule?
Target group,
Condition,
Priority.
Forwarding happens when the condition is met.
Can a target for a load balancer belong to more than one target group?
Yes.
What is ELB? What are the features?
Elastic Load Balancing. It automatically distributes incoming application traffic across multiple targets and virtual appliances in one or more Availability Zones (AZs).
- Single point of access (DNS)
- Handles failures of downstream instances
- Does health checks
- Provides HTTPS
- Enforce stickiness with cookies
- High availability across zones
- Separates private and public traffic
- Security (use with security groups)
- Monitoring (integrates with CloudWatch, request tracing)
What are the 4 types of load balancers?
Classic CLB
Application ALB
Network NLB
Gateway GWLB
I have some third-party virtual appliances. Which load balancer should I choose?
Gateway Load Balancer.
I need flexible application management, using Lambda functions and redirects. Which load balancer should I choose?
Application Load Balancer.
I need extreme performance and a static IP address. Which load balancer should I choose?
Network Load Balancer.
What does it mean to scale vertically? What kind of application would do that?
Make your instance bigger, like micro to large.
Non-distributed applications like databases would scale vertically.
Describe an Application Load Balancer.
Works at the application layer (layer 7).
• HTTP
• Supports HTTP/2, WebSocket
• Supports content-based routing (e.g. IP address, the path or hostname in the URL, or query string/headers in request)
• Can route to targets on the same instance: good for applications that run in containers
• Supports redirects (e.g. HTTP -> HTTPS)
• 1 ALB can support many applications
• Fixed hostname
Good for:
• Microservices
• Containers
Describe a Classic Load Balancer.
Previous-generation load balancer; no longer recommended. • TCP (layer 4) • HTTP/HTTPS (layer 7) • fixed hostname • one application = 1 load balancer
Describe a Network Load Balancer.
Works at layer 4
• TCP/UDP
• Ultra-low latency, extreme performance
Has 1 Static IP per AZ
Supports Elastic IP (good for white-listing)
Supports VPC endpoint services
Different listener on unique ports
Target can be outside your VPC like on-prem
What can be in a target group of an NLB?
EC2 instances
Private IP addresses
• specify fixed static IP address
• e.g. if you have a server in your own datacenter
ALB
• you can chain NLB to ALB
• e.g. you want to use the static IPs of the NLB but also the HTTP features of the ALB
Describe a Gateway Load Balancer
Operates at Level 3 (Network Layer - IP packets)
- Works as Load Balancer
- ALSO works as Transparent Network Gateway (single entry/exit point for all traffic)
Allows you to deploy/manage/scale a fleet of 3rd party network virtual appliances in AWS. These appliances sit between your users and the targets.
Users -> GLB -> appliances -> GLB -> target
E.g. You want all traffic to be inspected for security
I need to use the GENEVE protocol on port 6081.
Gateway Load Balancer.
What can be in a target group of the Gateway Load Balancer?
EC2.
Private IP addresses
What is a sticky session? How does it work? What are the pros and cons?
Aka Affinity Session.
An optional feature for CLB & ALB
Uses a cookie with an expiration date
Allows user to always communicate with the same EC2
Pros: keep session data like login ID
Cons: unbalanced load
What are the 2 types of cookie used for sticky sessions?
Application Based:
a) Custom
• generated by target (application)
• can include custom attributes required by the app
• must have a different name for each target group
• name is anything except AWSALB, AWSALBAPP, AWSALBTG
b) Application cookie:
• generated by load balancer
• name is AWSALBAPP
Duration Based:
• generated by load balancer
• name is AWSALB or AWSELB (for classic)
What are the potential target groups for an ALB?
EC2 instances
ECS tasks
Lambda functions
Private IP addresses
ALB can route to multiple target groups
What is Cross-Zone Load Balancing? When can you use it and when do you pay?
Allows you to distribute traffic evenly ACROSS AZs, regardless of where the load balancer is.
ALB: always on (can’t turn it off), free inter-AZ data
NLB: off by default, pay for inter-AZ data
CLB: off by default, free inter-AZ data
Describe SSL and TLS
Ways to encrypt your data in transit.
Secure Sockets Layer
Transport Layer Security (newer version but people still say SSL)
Certificates are issued by CA and have expiration date.
How does SSL/TLS work with a Load Balancer?
- Traffic comes in to ELB encrypted
- ELB uses x.509 cert (SSL/TLS cert)
- You can manage certs in AWS Certificate Manager
For the ELB listener (HTTPS listener):
• you must specify a default cert
• you can optionally add certs to support multiple domains
• clients can use SNI (Server Name Indication) to specify the hostname they want
• you can specify a security policy for older versions of SSL/TLS
What is SNI and how does it work?
Server Name Indication.
• Solves the problem of loading multiple certs onto 1 webserver
• Newer protocol, the client has to indicate the hostname of the target in the initial handshake, then the server finds the correct cert (or default one)
Only works for ALB, NLB, CloudFront.