High Availability and Scalability: ELB & ASG Flashcards

1
Q

What are the 4 goals of an Auto Scaling Group?

A
  1. Add EC2 instances to match an increased load
  2. Remove EC2 instances to match a decreased load
  3. Ensure we have min and max number of machines running
  4. Automatically register new instances to a load balancer
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

True or False

It is possible to scale an ASG based on CloudWatch alarms

A

True

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

ASG scaling policies are based on what?

A

Any metric you want. It can be CPU, Network, or even more custom metrics or based on a schedule (if you know your visitors’ patterns)

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

What is the pricing for ASG?

A

ASG are free. You pay for underlying resources being launched.

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

When will ASG terminate instances?

A

ASG will terminate instances marked as unhealthy by a load balancer and replace them with a new instance

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

Name the 4 ASG Scaling Policies

A

Target Tracking Scaling
eg. I want average CPU to stay around 40%

Simple / Step Scaling
eg. When alarm triggered, add 2 units

Scheduled Actions
eg. increased min capacity to 10 on Fridays

Predictive Scaling
continuously forecast load and schedule scaling ahead

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

Good metrics to scale ASG on?

A
  • CPU Utilization
  • request counts per target
  • average network in / network out
  • any custom metric in CloudWatch
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is an ASG scaling cooldown?

A

After scaling activity happens, there is a cooldown period where ASG will not launch or terminate instances.

This time is to allow metrics to stabilize.

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

How does ASG default termination policy work?

A
  1. Find AZ with most number of instances
  2. If multiple instances in AZ to choose from, delete the one with the oldest launch configuration
  3. ASG tries to balance number of instances across AZ
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

When can you add lifecycle hooks into ASG?

A
  1. between pending and in service

2. between terminating and terminated

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

Pros/Cons of Launch Template vs Launch Configuration in ASG

A

With Launch Templates (newer) you can:

  • have multiple versions
  • create parameter subsets
  • provision using on-demand or spot instances (or mix)
  • can utilize T2 unlimited burst feature
  • must only be created once
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

You scale an EC2 instance from r4.large to r4.4xlarge.

Is this vertical or horizontal scalability?

A

Vertical Scalability

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

You run an application on an Auto Scaling Group that scales the number of EC2 instances.

Is this vertical or horizontal scalability?

A

Horizontal Scalability

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

True or False

Elastic Load Balancers provide a static DNS name we can use in our application.

A

True.

Only Network Load Balancer provides both static DNS name and static IP. While, Application Load Balancer provides a static DNS name but it does NOT provide a static IP. The reason being that AWS wants your Elastic Load Balancer to be accessible using a static endpoint, even if the underlying infrastructure that AWS manages changes.

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

You are running a website on 10 EC2 instances fronted by an Elastic Load Balancer. Your users are complaining about the fact that the website always asks them to re-authenticate when they are moving between website pages. You are puzzled because it’s working just fine on your machine and in the Dev environment with 1 EC2 instance. What could be the reason?

A

The ELB does not have Stick Sessions enabled.

ELB Sticky Session feature ensures traffic for the same client is always redirected to the same target (e.g., EC2 instance). This helps that the client does not lose his session data.

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

You are using an Application Load Balancer to distribute traffic to your website hosted on EC2 instances. It turns out that your website only sees traffic coming from private IPv4 addresses which are in fact your Application Load Balancer’s IP addresses. What should you do to get the IP address of clients connected to your website?

A

Modify your website’s backend to get the client IP address from the X-Forwarded-For header.

When using an Application Load Balancer to distribute traffic to your EC2 instances, the IP address you’ll receive requests from will be the ALB’s private IP addresses. To get the client’s IP address, ALB adds an additional header called “X-Forwarded-For” contains the client’s IP address.

17
Q

You hosted an application on a set of EC2 instances fronted by an Elastic Load Balancer. A week later, users begin complaining that sometimes the application just doesn’t work. You investigate the issue and found that some EC2 instances crash from time to time.

What should you do to protect users from connecting to the EC2 instances that are crashing?

A

Enable ELB Health Checks.

When you enable ELB Health Checks, your ELB won’t send traffic to unhealthy (crashed) EC2 instances.

18
Q

You are working as a Solutions Architect for a company and you are required to design an architecture for a high-performance, low-latency application that will receive millions of requests per second.

Which type of Elastic Load Balancer should you choose?

A

Network Load Balancer provides the highest performance and lowest latency if your application needs it.

19
Q

Application Load Balancers support the following protocols, EXCEPT:

a. HTTP
b. HTTPS
c. TCP
d. WebSocket

A

c. TCP

Application Load Balancers support HTTP, HTTPS and WebSocket

20
Q

Application Load Balancers can route traffic to different Target Groups based on the following, EXCEPT:

a. Client’s location (geography)
b. Hostname
c. Request URL Path
d. Source IP Address

A

a. Client’s location (geography)

ALBs can route traffic to different Target Groups based on URL Path, Hostname, HTTP Headers, and Query Strings.

21
Q

Registered targets in a Target Groups for an Application Load Balancer can be one of the following, EXCEPT:

a. EC2 Instances
b. Network Load Balancer
c. Private IP Addresses
d. Lambda Functions

A

b. Network Load Balancer

22
Q

For compliance purposes, you would like to expose a fixed static IP address to your end-users so that they can write firewall rules that will be stable and approved by regulators.

What type of Elastic Load Balancer would you choose?

a. Application Load balancer with an elastic IP attached to it
b. Network load balancer
c. Classic load balancer

A

b. Network load balancer

Network Load Balancer has one static IP address per AZ and you can attach an Elastic IP address to it. Application Load Balancers and Classic Load Balancers have a static DNS name.

Application load balancers can not have an elastic IP attached to them.

23
Q

You want to create a custom application-based cookie in your Application Load Balancer. Which of the following you can use as a cookie name?

a. AWSALBAPP
b. APPUSERC
c. AWSALBTG
d. AWSALB

A

b. APPUSERC

The following cookie names are reserved by the ELB (AWSALB, AWSALBAPP, AWSALBTG).

24
Q

You have a Network Load Balancer that distributes traffic across a set of EC2 instances in us-east-1. You have 2 EC2 instances in us-east-1b AZ and 5 EC2 instances in us-east-1e AZ. You have noticed that the CPU utilization is higher in the EC2 instances in us-east-1b AZ. After more investigation, you noticed that the traffic is equally distributed across the two AZs.

How would you solve this problem?

A

Enable cross-zone load balancing.

When Cross-Zone Load Balancing is enabled, ELB distributes traffic evenly across all registered EC2 instances in all AZs.

25
Q

Which feature in both Application Load Balancers and Network Load Balancers allows you to load multiple SSL certificates on one listener?

A

server name indication (SNI)

26
Q

You have an Application Load Balancer that is configured to redirect traffic to 3 Target Groups based on the following hostnames:

users. example.com,
api. external.example.com, and
checkout. example.com.

You would like to configure HTTPS for each of these hostnames. How do you configure the ALB to make this work?

A

Server Name Indication (SNI) allows you to expose multiple HTTPS applications each with its own SSL certificate on the same listener.

Read more here: https://aws.amazon.com/blogs/aws/new-application-load-balancer-sni/

27
Q

You have an application hosted on a set of EC2 instances managed by an Auto Scaling Group that you configured both desired and maximum capacity to 3. Also, you have created a CloudWatch Alarm that is configured to scale out your ASG when CPU Utilization reaches 60%.

Your application suddenly received huge traffic and is now running at 80% CPU Utilization. What will happen?

A

Nothing. The Auto Scaling Group can’t go over the maximum capacity (you configured) during scale-out events.

28
Q

You have an Auto Scaling Group fronted by an Application Load Balancer. You have configured the ASG to use ALB Health Checks, then one EC2 instance has just been reported unhealthy.

What will happen to the EC2 instance?

A

The ASG will terminate the EC2 instance.

You can configure the Auto Scaling Group to determine the EC2 instances’ health based on Application Load Balancer Health Checks instead of EC2 Status Checks (default). When an EC2 instance fails the ALB Health Checks, it is marked unhealthy and will be terminated while the ASG launches a new EC2 instance.

29
Q

Your boss asked you to scale your Auto Scaling Group based on the number of requests per minute your application makes to your database.

What should you do?

A

You need to create a CloudWatch Custom Metric, then create a CloudWatch Alarm. There’s no CloudWatch Metric for “requests per minute” for backend-to-database connections.

30
Q

A web application hosted on a fleet of EC2 instances managed by an Auto Scaling Group. You are exposing this application through an Application Load Balancer. Both the EC2 instances and the ALB are deployed on a VPC with the following CIDR 192.168.0.0/18.

How do you configure the EC2 instances’ security group to ensure only the ALB can access them on port 80?

A

Add an inbound rule with port 80, and ALB’s security group as the source.

This is the most secure way of ensuring only the ALB can access the EC2 instances. Referencing by security groups in rules is an extremely powerful rule.

31
Q

There is an Auto Scaling Configured running in eu-west-2 region, that is configured to spawn into two Availability Zones eu-west-2a and eu-west-2b. Currently, 3 EC2 instances are running in eu-west-2a and 4 EC2 instances are running in eu-west-2b. The ASG is about to scale in.

Which EC2 instance will get terminated?

A

The EC2 instance in eu-west-2b with the oldest launch template version.

Make sure you remember the Default Termination Policy for Auto Scaling Group. It tries to balance across AZs first, then terminates based on the age of the Launch Configuration.

32
Q

An application is deployed with an Application Load Balancer and an Auto Scaling Group. Currently, you manually scale the ASG and you would like to define a Scaling Policy that will ensure the average number of connections to your EC2 instances is around 1000.

Which Scaling Policy should you use?

A

Target tracking policy

33
Q

Your application hosted on EC2 instances managed by an Auto Scaling Group suddenly receives a spike in traffic which triggers your ASG to scale out and a new EC2 instance has been launched. The traffic continuously increases but the ASG doesn’t launch any new EC2 instances immediately but after 5 minutes.

What is a possible cause for this behavior?

A

Cooldown Period

For each Auto Scaling Group, there’s a Cooldown Period after each scaling activity. In this period, the ASG doesn’t launch or terminate EC2 instances. This gives time to metrics to stabilize. The default value for the Cooldown Period is 300 seconds (5 minutes).