Section 7: AWS Fundamentals: ELB + ASG Flashcards

1
Q

Elastic Load Balancer

A

A server that forwards traffic to multiple servers (e.g., EC2 instances) downstream. It’s a managed load balancer.

Users can access load balancers from anywhere using HTTPS/HTTP

Reasons for using a load balancer:
1. Spread load across multiple downstream instances.
2. Expose a single point of access (DNS) to your application.
3. Seamlessly handle failures of downstream instances.
4. Do regular health checks to your instances.
5. Provide SSL termination (HTTPS) for your websites.
6. Enforce stickiness with cookies.
7. High availability across zones.
8. Separate public traffic from private traffic.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Health Checks

A

They let the load balancer to know if instances it forwards traffic to are available to reply to requests.

The health check is done on a port and a route.

If the response is not 200 (OK), then the instance is unhealthy.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Application Load Balancer (ALB)

A

v2 - new generation

Year: 2016

Layer 7 (HTTP)

Load balancing to multiple HTTP applications across machines (target groups). Load balancing to multiple applications on the same machine (ex: containers).

Support for HTTP/2 and Websocket. Supports redirects (from HTTP to HTTPS for example).

Routing tables can be based on path in URL, hostname in URL, or query string and headers.

Great for microservices & container-based applications.

Has a port mapping feature to redirect to a dynamic port in ECS.

Can route based on which application the user is engaging with.

Has a fixed hostname. The application servers don’t see the IP of the client directly. The tru IP of the client is inserted in the header X-Forwarded-For. We can also get Port (X-Forwarded-Port) and proto (X-Forwarded-Proto)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Network Load Balancer (NLB)

A

v2 - new generation

Year: 2017

Layer 4

Forward TCP & UDP traffic to your instances. Handle millions of requests per second. Ultra-low latency.

NLB has one static IP per AZ, and supports assigning Elastic IP.

Used for extreme performance, TCP or UDP traffic. Not included in the AWS free tier.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Gateway Load Balancer (GWLB)

A

Year: 2020

Operates at layer 3 (Network layer) - IP Protocol

Deploy, scale, and manage a fleet of 3rd party network virtual appliances in AWS.

Example: Firewalls, Intrusion Detection and Prevention Systems, Deep Packet Inspection Systems, payload manipulation,…

Can forward traffic to and from target group, and then to application (destination).

Combines the following functions:
- Transparent Network Gateway - single entry/exit for all traffic
- Load Balancer - distributes traffic to your virtual appliances

Uses the GENEVE protocol on port 6081

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

ALB Target Groups

A

EC2 instances - HTTP
ECS tasks - HTTP
Lambda functions - HTTP request is translated into a JSON event
IP Addresses - must be private IP’s

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

NLB Target Groups

A

EC2 instances
IP Addresses - must be private IP’s
Application Load Balancer
Health checks support the TCP, HTTP and HTTPS Protocols

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

GWLB Target Groups

A

EC2 instances
IP Addresses - must be private IP’s

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Sticky Sessions: Session Affinity

A

This is when you implement stickiness so that the same client is always redirected to the same instance behind a load balancer.

This works for CLB, ALB, and NLB.

The “cookie” used for stickiness has an expiration date you control.

Great for making sure the user doesn’t lose his session data.

Enabling stickiness may bring imbalance to the load over the backend EC2 instances.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Sticky Sessions: Application-based Cookies

A

Application-based Cookies
1. Custom cookie: generated by the target; can include any custom attributes required by the application; cookie name must be specified individually for each target group; don’t use AWSALB, AWSALBAPP, or AWSALBTG (reserved for use by the ELB)
2. Application cookie: generated by the load balancer; cookie name is AWSALBAPP

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Sticky Sessions: Duration-based Cookies

A

Cookie generated by the load balancer. Cookie name is AWSALB for ALB, AWSELB for CLB.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Cross-Zone Load Balancing

A

Each load balancer instance distributes evenly across all registered instances in all AZ’s.

Without Cross-Zone Load Balancing, requests are distributed in the instances of the node of the Elastic Load Balancer. If there are two AZ’s, each AZ gets 50% of the traffic, with the EC2 Instances in each AZ splitting the incoming traffic equally.

ALB enables this by default. No charges for inter AZ data.

NLB & GWLB disable this by default. You pay for charges for inter AZ data if enabled.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

SSL/TLS - Basics

A

An SSL Certificate allows traffic between your clients and your load balancer to be encrypted in transit (in-flight encryption).

SSL refers to Secure Sockets Layer, used to encrypt connections.

TLS refers to Transport Layer Security, which is a newer version.

Nowadays, TLS certificates are mainly used, but people still refer as SSL.

SSL certificates have an expiration date that you set, and must be renewed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Load Balancer - SSL Certificates

A

The load balancer uses an X.509 certificate (SSL/TLS server certificate). You can manage certificates using ACM (AWS Certificate Manager). You can create upload your own certificates.

HTTPS listener:
- You must specify a default certificate
- You can add an optional list of certs to support multiple domains
- Clients can use SNI (Server Name Indication) to specify the hostname they reach
- Ability to specify a security policy to support older versions of SSL/TLS (legacy clients)

ALB supports multiple listeners with multiple SSL certificates. Uses SNI to make it work.

NLB supports multiple listeners with multiple SSL certificates. Uses SNI to make it work.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

SSL - Server Name Indication (SNI)

A

SNI solves the problem of loading multiple SSL certificates onto one web server (to serve multiple websites).

It’s a newer protocol, and requires the client to indicate the hostname of the target server in the initial SSL handshake.

The server will then find the correct certificate, or return the default one.

SNI only works for ALB & NLB, CloudFront.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Connection Draining

A

Called “Deregistration Delay” for ALB & NLB.

Time to complete “in-flight requests” while the instance is de-registering or unhealthy.

Stops sending new requests to the EC2 instance which is de-registering.

Between 1 to 3600 seconds (default: 300 seconds).

Can be disabled (set value to 0).

Set to a low value if your requests are short.

17
Q

Auto Scaling Group

A

The main goal is to scale out (add EC2 instances) to match an increased load, or to scale in (remove EC2 instances) to match a decreased load.

It ensures we have a minimum and maximum number of EC2 instances running.

It automatically registers new instances to a load balancer.

It recreates an EC2 instance in case a previous one is terminated.

ASG itself is free, but you pay for the underlying instances.

Attributes:
- Launch Template: AMI + Instance Type, EC2 User Data, EBS Volumes, Security Groups, SSH Key Pair, IAM Roles for your EC2 Instances, Network + Subnets Information, Load Balancer Information
- Min Size / Max Size / Initial Capacity

18
Q

CloudWatch Alarms & Scaling

A

Can scale an ASG based on CloudWatch Alarms.

An alarm monitors a metric (such as Average CPU, or a custom metric).

Metrics are computed for the overall ASG instances.

19
Q

Scaling Policies

A

Dynamic Scaling
Target Tracking Scaling:
- Simple to set-up
- Ex: average ASG CPU should stay around 40%

Simple/Step Scaling
- Ex: When a CloudWatch alarm is triggered (ex. CPU > 70%), then add 2 units

Scheduled Scaling
- Anticipate a scaling based on known usage patterns
- Ex: increase the min capacity to 10 at 5:00 p.m. on Fridays

Predicting Scaling
- continuously forecast load and schedule scaling ahead

20
Q

Metrics to Scale On

A
  • CPUUtilization: average CPU utilisation across your instances
  • RequestCountPerTarget: to make sure the number of requests per EC2 instances is stable
  • Average Network In/Out (if you’re application is network bound)
  • Any custom metric (that you push using CloudWatch)
21
Q

Scaling Cooldowns

A
  • After a scaling activity happens, you are in the cooldown period (default 300 sec)
  • During the cooldown period, the ASG will not launch or terminate additional instances
  • Use a read-to-use AMI to reduce configuration time in order to be serving requests faster and reduce the cooldown period
22
Q

Instance Refresh

A

Great for updating launch template and then re-creating all EC2 instances.

Can set minimum healthy percentage.

Can specify warm-up time (how long until the instance is ready to use).