Tutorial / Cram Notes

It involves the distribution of network or application traffic across a number of servers, ensuring no single server bears too much demand. By spreading the load, this strategy enhances the responsiveness and availability of applications. AWS provides several load balancing solutions, and configuring them requires understanding their features, use cases, and how to implement them effectively.

Types of AWS Load Balancers

AWS offers three main types of load balancers, each with its distinct characteristics:

  • Application Load Balancer (ALB): Suitable for HTTP/HTTPS traffic, ALBs operate at Layer 7 and offer advanced request routing targeted at the delivery of modern application architectures, including microservices and container-based applications.
  • Network Load Balancer (NLB): Designed for TCP/UDP traffic where extreme performance is required, NLBs operate at Layer 4 and are capable of handling millions of requests per second while maintaining ultra-low latencies.
  • Classic Load Balancer (CLB): This is the legacy load balancer operating at both Layer 4 and Layer 7, suitable for applications that were built within the EC2-Classic network.
Load Balancer Type Suitable for Operates at Features
ALB HTTP/HTTPS traffic Layer 7 Content-based routing, host-based routing, path-based routing, SSL/TLS offloading, WebSocket and HTTP/2 support
NLB TCP/UDP traffic Layer 4 High performance, static IP per AZ, Elastic IP support, preserves client IP
CLB Legacy applications Layer 4/7 Basic load balancing, SSL/TLS offloading, supports EC2-Classic

Configuring an Application Load Balancer

To create an ALB, follow these steps:

  1. Create the load balancer: Define your ALB with a name, scheme (internet-facing or internal), and the listeners (typically HTTP on port 80 and HTTPS on port 443).
  2. Define security settings: If handling HTTPS traffic, upload an SSL certificate to IAM or ACM and select the appropriate security policy.
  3. Configure security groups: Set up security groups that allow inbound traffic on the necessary ports and outbound traffic to the target EC2 instances.
  4. Setup the routing: Define target groups which are basically sets of instances that receive traffic from the load balancer. Specify how to route requests (path-based, host-based, etc.).
  5. Register targets: Add EC2 instances to the target groups. The ALB will perform health checks on these instances to ensure traffic is only routed to healthy instances.
  6. Adjust advanced settings: Modify session stickiness, idle timeout, and HTTP/2 settings as required by your application.

Example AWS CLI command to create an ALB:

aws elbv2 create-load-balancer –name my-load-balancer –subnets subnet-abcde012 subnet-bcde012a –security-groups sg-a12345c6 –scheme internet-facing

Configuring a Network Load Balancer

Creating an NLB involves:

  1. Create the load balancer: Define your NLB with a name, choose whether it’s internet-facing or internal, and establish listeners for your TCP/UDP traffic.
  2. Configure target groups: Define the group of instances that will receive traffic based on a specific port and protocol.
  3. Register targets: Add instances to your target groups. NLBs perform health checks similarly to ALBs.
  4. Set up networking: Assign elastic IPs if needed, and make sure your security groups allow the necessary traffic to and from the NLB.

Example AWS CLI command to create an NLB:

aws elbv2 create-load-balancer –name my-nlb –subnets subnet-abcde012 subnet-bcde012a –type network –scheme internet-facing

Considerations for Load Balancing

  • Cost: NLBs are generally more expensive than ALBs or CLBs due to their high performance.
  • Performance Needs: Choose an NLB for ultra-high performance and a low latency; use ALBs for content-based routing or if leveraging advanced HTTP/HTTPS features.
  • Health Checks: Properly configure health checks to ensure traffic is not sent to failed instances.
  • SSL Termination: For secure transmissions, ALBs and CLBs can handle SSL termination, reducing the encryption/decryption load on your servers.

Load balancing is an intricate part of ensuring the high availability and fault tolerance of your AWS workloads. Properly configuring and implementing the right type of load balancer can have a large impact on the responsiveness and scalability of your applications. As part of preparing for the AWS Certified Advanced Networking – Specialty (ANS-C01) exam, you’ll need to understand these concepts in depth and be able to apply them in various scenarios.

Practice Test with Explanation

True or False: Amazon Route 53 cannot route traffic to multiple AWS regions.

  • A) True
  • B) False

Answer: B) False

Explanation: Amazon Route 53 is a DNS service that allows you to route traffic to different AWS regions for high availability and disaster recovery.

Which AWS service is a global Content Delivery Network (CDN) service that securely delivers data, videos, applications, and APIs to customers globally with low latency and high transfer speeds?

  • A) AWS Direct Connect
  • B) AWS Global Accelerator
  • C) Amazon CloudFront
  • D) Amazon Route 53

Answer: C) Amazon CloudFront

Explanation: Amazon CloudFront is a fast content delivery network (CDN) service that securely delivers data and applications to customers globally with low latency and high speeds.

True or False: Network Load Balancer (NLB) operates at the transport layer (Layer 4) of the OSI model and can handle millions of requests per second.

  • A) True
  • B) False

Answer: A) True

Explanation: Network Load Balancer operates at Layer 4 and is designed to handle millions of requests per second while maintaining ultra-low latencies.

What is the main benefit of using Application Load Balancer (ALB) over Classic Load Balancer (CLB)?

  • A) Support for static IP addresses
  • B) Advanced routing based on the content of the request
  • C) Transport Layer Security (TLS) termination
  • D) Works only with EC2 instances

Answer: B) Advanced routing based on the content of the request

Explanation: Application Load Balancer offers advanced request routing compared to Classic Load Balancer, which is useful for modern application architectures.

True or False: It is possible to perform SSL/TLS offloading with AWS Elastic Load Balancing.

  • A) True
  • B) False

Answer: A) True

Explanation: SSL/TLS offloading can be performed with AWS Elastic Load Balancing, reducing the load on the application instances by handling the encryption/decryption process.

AWS Global Accelerator improves application performance by using what technology?

  • A) Anycast IP addresses
  • B) Classic Load Balancing
  • C) A/B testing
  • D) Edge Locations

Answer: A) Anycast IP addresses

Explanation: AWS Global Accelerator improves application performance by using the AWS global network infrastructure and Anycast IP addresses.

Which feature of Elastic Load Balancing allows you to distribute incoming application traffic across multiple target groups based on request attributes?

  • A) SSL Termination
  • B) Sticky Sessions
  • C) Path-Based Routing
  • D) Cross-Zone Load Balancing

Answer: C) Path-Based Routing

Explanation: Path-Based Routing is a feature of ALB that allows you to route traffic to different target groups based on the URL path specified in the request.

True or False: Elastic Load Balancing automatically distributes incoming application traffic across multiple Amazon EC2 instances, containers, and IP addresses in the cloud.

  • A) True
  • B) False

Answer: A) True

Explanation: Elastic Load Balancing automatically distributes incoming application traffic across multiple targets, such as Amazon EC2 instances, containers, and IP addresses.

What is NOT a common use case for AWS Network Load Balancer (NLB)?

  • A) Routing millions of requests per second
  • B) Handling volatile workloads with millisecond latencies
  • C) Layer 7 content-based routing
  • D) Supporting static or elastic IP addresses

Answer: C) Layer 7 content-based routing

Explanation: AWS Network Load Balancer operates at Layer 4, not Layer 7; thus, it does not provide content-based routing, which is a feature of Application Load Balancer.

Sticky sessions are a feature of which Elastic Load Balancing types?

  • A) Application Load Balancer and Network Load Balancer
  • B) Classic Load Balancer only
  • C) Classic Load Balancer and Application Load Balancer
  • D) Network Load Balancer only

Answer: C) Classic Load Balancer and Application Load Balancer

Explanation: Sticky sessions are a feature available in both the Classic Load Balancer and Application Load Balancer, which help maintain user session state.

Interview Questions

Can you explain the different types of load balancers offered by AWS and in which scenarios each type would be most appropriately used?

AWS offers three types of load balancers:

  • Classic Load Balancer (CLB): Best suited for simple load balancing of traffic across multiple EC2 instances. It operates at both Layer 4 and Layer
  • Network Load Balancer (NLB): Operates at Layer 4, ideal for load balancing TCP/UDP traffic where extreme performance and static IP is necessary for each Availability Zone.
  • Application Load Balancer (ALB): Operates at Layer 7, best for advanced load balancing of HTTP/HTTPS traffic, providing advanced request routing targeting the delivery of modern application architectures, including microservices and containers.

What is the difference between cross-zone load balancing and sticky sessions?

Cross-zone load balancing allows load balancer nodes to distribute traffic evenly across all registered instances in all enabled Availability Zones, while sticky sessions enable the load balancer to bind a user’s session to a specific instance so all requests from the user during the session are sent to the same instance.

Describe how you would design a high availability architecture using load balancers in AWS.

A high availability architecture would involve deploying load balancers across multiple Availability Zones, registering instances in each AZ to the load balancer, enabling cross-zone load balancing to ensure even traffic distribution, and ensuring that the application replicates its state across instances if stateful. Route 53 could also be used to provide DNS failover to re-route traffic in case the load balancer fails.

How can an AWS load balancer be made part of a VPC?

Load balancers can be placed inside VPC by first creating a VPC, then defining subnet(s) across different AZs. When creating the load balancer, you choose the VPC and assign it to one or more subnets. The load balancer will then work within the confines of the selected VPC.

What methods can be used to secure a load balancer in AWS?

To secure a load balancer in AWS, you can use the following methods:

  • Configure security groups to restrict traffic to the load balancer.
  • Enable AWS Shield for DDoS protection.
  • Use AWS WAF to control the traffic that can reach the application.
  • Implement SSL/TLS certificates for secure data in transit.
  • Use access logs to record and monitor requests to the load balancer.

How does connection draining (deregistration delay) work with load balancers in AWS and why is it important?

Connection draining, also known as deregistration delay, ensures that the load balancer stops sending requests to instances that are deregistering or unhealthy, while keeping existing connections alive until they complete or a timeout is reached (configurable). This is important for maintaining a smooth user experience and avoiding abrupt termination of active sessions.

How can AWS load balancers handle sudden spikes in web traffic?

AWS load balancers can handle traffic spikes by automatically scaling their request handling capacity in response to incoming traffic volumes. Additionally, integrating with Auto Scaling groups allows for dynamic adjustment of the number of instances behind the load balancer to match the load.

Describe the process of monitoring AWS load balancers and the types of metrics you would track.

AWS load balancers are monitored using Amazon CloudWatch, which provides metrics on request count, request latency, HTTP codes returned, and backend connection errors, among others. It is crucial to track metrics related to the performance and health of the load balancer and the instances it is distributing traffic to.

What is the difference between path-based routing and host-based routing in Application Load Balancers?

Path-based routing directs requests to different backend services based on the request URL path, whereas host-based routing uses the hostname in the request header to determine the target group for request forwarding. This enables support for multiple domains using a single load balancer.

Can AWS Network Load Balancers preserve the client’s source IP, and if so, how?

Yes, AWS Network Load Balancers preserve the client’s source IP by providing support for transparent network load balancing, which means the IP address is sent through to the destination instances without modification. This allows applications to see the address for client-specific handling.

In the context of AWS, explain the role of health checks in load balancing solutions.

Health checks are used by AWS load balancers to automatically check the health of the instances. If an instance fails health checks, it is considered unhealthy and removed from the rotation for load balancing until it passes health checks again. This ensures that traffic is not sent to failed or degraded instances.

How can AWS’s Elastic Load Balancing service integrate with other AWS services to provide an end-to-end traffic management solution?

AWS Elastic Load Balancing can integrate with a variety of AWS services such as:

  • Amazon EC2 for automatic distribution of load across instances.
  • Amazon Route 53 for DNS and traffic routing.
  • AWS Auto Scaling to automatically adapt the number of instances in response to varying load.
  • AWS CloudFormation for infrastructure as code deployment including load balancers.
  • AWS Certificate Manager for SSL/TLS certificate management.
  • AWS WAF and Shield for application security against common web exploits and DDoS protection, respectively.

Please note, given the dynamic nature of cloud services and specific feature details, it’s important for any AWS Advanced Networking Specialty candidate to verify the latest AWS documentation and best practices ahead of their exam or interview.

0 0 votes
Article Rating
Subscribe
Notify of
guest
37 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Aras Gashi
5 months ago

Great post! Learned a lot about configuring ALB and NLB.

Ilan Fabre
6 months ago

Thanks for the detailed guide. Helped me set up load balancing in my AWS environment.

Catalina Muñoz
5 months ago

I’ve got a question. What’s the best way to shift traffic between multiple AWS regions using Route 53?

Aron Fogaça
5 months ago

Using Route 53, you can configure latency-based routing policies to route user traffic to the AWS region that provides the lowest latency.

Emily Andersen
6 months ago

Can you explain the difference between NLB and ALB?

Alicia Diez
6 months ago
Reply to  Emily Andersen

NLB operates at the transport layer (Layer 4) and is best for extreme performance and static IP addresses, while ALB operates at the application layer (Layer 7) and is better for HTTP/HTTPS traffic.

Hector Price
6 months ago

Excellent article. Helped me pass my AWS Certified Advanced Networking – Specialty exam!

Julius Staab
6 months ago

Can AWS load balancers handle SSL termination?

Randall Price
6 months ago
Reply to  Julius Staab

Yes, both ALB and NLB can handle SSL termination. Just make sure to upload your SSL certificates to the load balancer.

Antonia Serrano
6 months ago

This tutorial could use more real-world examples.

Peppi Rintala
6 months ago

Brilliant guide! Covered everything I needed to know.

37
0
Would love your thoughts, please comment.x
()
x