Tutorial / Cram Notes

AWS offers three types of load balancers that cater to different use cases:

  • Application Load Balancer (ALB): Operates at the request level and is best suited for HTTP/HTTPS traffic. It can make advanced routing decisions based on content, such as URLs and headers.
  • Network Load Balancer (NLB): Operates at the TCP layer and is ideal for handling millions of requests per second while maintaining ultra-low latencies. It is suitable for TCP, UDP, and TLS traffic.
  • Classic Load Balancer (CLB): Offers basic load balancing at both the request level and the connection level. It is now considered legacy and AWS recommends using ALBs or NLBs for new applications.

Comparison Table of AWS Load Balancers

Feature Application Load Balancer Network Load Balancer Classic Load Balancer
Protocol Level Layer 7 (Application) Layer 4 (Transport) Layer 4 & 7
Routing Algorithms Content-based Flow Hash Round Robin
Use Cases Web applications High Performance Legacy Applications
Performance High (millions of req/s) Very High Moderate
SSL/TLS Offloading Yes Yes (SNI) Yes
Static/Elastic IP Elastic IP Support Static IP & Elastic IP None
HTTP/2 and WebSocket Supported TCP, not HTTP/2 HTTP only
IP as Target Yes Yes No
Multi-AZ Support Yes Yes Yes

Traffic Distribution Patterns

Weighted Round Robin

Traffic is distributed across multiple targets, such as EC2 instances, containers, and IP addresses, with each target assigned a weight that determines the proportion of requests it receives. This pattern is great for blue/green deployments or slowly shifting traffic towards new versions of an application.

Least Outstanding Requests

Often used by ALBs, this algorithm favors targets with the fewest in-flight requests, which can help ensure that no single target is overwhelmed by too many concurrent connections.

Hash-based Routing

NLBs use a hash-based routing algorithm where a flow hash is computed based on fields from the header, such as source IP, destination IP, source port, destination port, and the protocol. This ensures that packets of the same flow/session consistently hit the same target, important for maintaining session affinity.

Considerations for Effective Load Balancing

Cross-Zone Load Balancing

By default, ALB and NLB can route requests to targets in multiple Availability Zones. This feature increases fault tolerance and can lead to a more even distribution of traffic across zones.

Sticky Sessions

Application Load Balancers can use sticky sessions (also known as session affinity), which bind a user’s session to a specific target. This ensures that all requests from a user during the session are sent to the same target, which is useful for stateful applications.

Path-based Routing

With an ALB, you can route traffic to different backend services based on the URL path. This is beneficial in microservices architectures where different services are responsible for different parts of an application.

Health Checks

All AWS load balancers perform health checks on registered targets, and automatically route traffic away from unhealthy instances. Health check configuration, such as frequency and conditions, is critical for rapid detection of target health.

SSL/TLS Offloading

AWS load balancers can decrypt SSL/TLS traffic at the load balancer level, reducing the encryption burden on the application servers and simplifying certificate management.

When designing solutions for load balancing and traffic distribution, understanding the nuances of these patterns and the capabilities of AWS load balancers is crucial. The right choice and configuration of load balancing solutions can enhance an application’s availability, resilience, and user experience significantly. As technologies evolve, so too do these solutions and practices, underlining the value of AWS certification in ensuring practitioners are up-to-date with the current best practices.

Practice Test with Explanation

True/False: Load balancing only distributes traffic across multiple servers within a single availability zone.

  • Answer: False

Load balancing can distribute traffic across multiple servers located in different availability zones, increasing the fault tolerance and availability of applications.

Single Select: Which AWS service is a global Content Delivery Network (CDN) that can be used to distribute content with low latency?

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

Answer: C. Amazon CloudFront

Amazon CloudFront 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.

Multiple Select: Which of the following are types of load balancers offered by AWS? (Select two)

  • A. Application Load Balancer
  • B. Network Load Balancer
  • C. Classic Load Balancer
  • D. Direct Load Balancer

Answer: A. Application Load Balancer, B. Network Load Balancer

AWS offers three types of load balancers: Application Load Balancer, Network Load Balancer, and Classic Load Balancer. There is no such thing as a Direct Load Balancer in AWS.

True/False: The Network Load Balancer (NLB) operates at Layer 7 of the OSI model.

  • Answer: False

The Network Load Balancer operates at Layer 4 (Transport Layer) of the OSI model, providing high performance and static IP support for TCP traffic.

True/False: AWS Global Accelerator improves application availability and performance by using the AWS global network infrastructure.

  • Answer: True

AWS Global Accelerator directs traffic to optimal endpoints over the AWS global network, improving the performance and availability of user applications.

Single Select: Which feature of AWS allows routing based on geographic location of the user?

  • A. AWS Direct Connect
  • B. Amazon Route 53 Geolocation Routing
  • C. Amazon CloudFront with Lambda@Edge
  • D. Amazon VPC

Answer: B. Amazon Route 53 Geolocation Routing

Amazon Route 53 Geolocation Routing lets you choose where traffic will be sent based on the geographic location of your users.

Multiple Select: What are common traffic distribution patterns used in load balancing? (Select two)

  • A. Round Robin
  • B. Least Connections
  • C. Most Bandwidth
  • D. First Response

Answer: A. Round Robin, B. Least Connections

Round Robin and Least Connections are two common algorithms used for distributing client requests among a group of servers in a load-balanced environment.

True/False: Sticky sessions are not supported by the Application Load Balancer.

  • Answer: False

The Application Load Balancer supports sticky sessions, which bind a user’s session to a specific target, ensuring that all requests from the user during the session are sent to the same target.

Single Select: Which load balancer is best suited for handling millions of requests per second with very low latencies?

  • A. Classic Load Balancer
  • B. Application Load Balancer
  • C. Network Load Balancer
  • D. None of the Above

Answer: C. Network Load Balancer

Network Load Balancer is optimized to handle sudden and volatile traffic patterns while using a single static IP address per Availability Zone.

True/False: AWS Elastic Load Balancing (ELB) automatically scales its request handling capacity in response to incoming application traffic.

  • Answer: True

AWS Elastic Load Balancing (ELB) automatically distributes incoming application traffic across multiple targets and scales dynamically to handle changing traffic loads.

Single Select: Which load balancing algorithm does the AWS Classic Load Balancer use by default?

  • A. Round Robin
  • B. Least Outstanding Requests
  • C. Source IP Hash
  • D. Weighted Round Robin

Answer: A. Round Robin

The AWS Classic Load Balancer initially uses a Round Robin routing algorithm for load balancing.

Multiple Select: Which of the following are valid options for external load balancing on AWS? (Select two)

  • A. Elastic Load Balancing
  • B. AWS Direct Connect
  • C. Amazon Route 53
  • D. AWS Transit Gateway

Answer: A. Elastic Load Balancing, C. Amazon Route 53

Elastic Load Balancing can distribute external traffic among EC2 instances, containers, and IP addresses. Amazon Route 53 can perform DNS level load balancing to direct traffic across different endpoints. AWS Direct Connect and AWS Transit Gateway are connectivity services, not load balancers.

Interview Questions

What is the primary function of a load balancer in a cloud environment?

The primary function of a load balancer in a cloud environment is to distribute incoming network traffic across multiple targets such as EC2 instances, containers, and IP addresses, improving the reliability and availability of applications and services.

Can you describe the difference between a Network Load Balancer (NLB) and an Application Load Balancer (ALB) in AWS?

An Application Load Balancer operates at the application layer (Layer 7) and supports advanced routing based on HTTP/HTTPS headers and SSL termination. On the other hand, a Network Load Balancer operates at the transport layer (Layer 4) and is optimized for low latency, high throughput, and TCP/UDP traffic handling.

How does the AWS Elastic Load Balancing service ensure high availability and fault tolerance?

AWS Elastic Load Balancing provides high availability and fault tolerance by automatically distributing incoming application traffic across multiple targets and Availability Zones, enabling the load balancer to automatically adjust to changes in traffic patterns and healthy target instances.

What is cross-zone load balancing, and when would you enable it?

Cross-zone load balancing is a feature that enables the distribution of traffic evenly across all registered instances in all enabled Availability Zones. It is useful when you want to ensure balanced traffic distribution even when the number of instances in each zone may not be equal.

What are the differences between sticky sessions and a stateless traffic distribution pattern?

Sticky sessions (session affinity) bind a user’s session to a specific instance so that all requests from the user during the session are sent to the same instance. Stateless traffic distribution does not maintain any affinity, and each request can be handled by any one of the available instances based on current load and routing algorithm.

In AWS, how can you automatically scale the number of instances behind a load balancer based on traffic demand?

AWS Auto Scaling allows you to automatically scale the number of EC2 instances up or down based on specified conditions, such as CPU utilization or incoming request rate, to ensure that the traffic demand is met efficiently.

What are the benefits of using Amazon Route 53 in conjunction with Elastic Load Balancing?

Using Amazon Route 53 with Elastic Load Balancing allows for DNS level load balancing and high availability. Route 53 can direct traffic to multiple load balancers in different regions for geolocation routing, latency-based routing, health checks, and failover capabilities.

How does AWS Global Accelerator improve the user experience for global applications?

AWS Global Accelerator improves the user experience by optimizing the path from the user to the application, leveraging AWS’s global network infrastructure for lower latency and more consistent transfer speeds than standard internet routing.

When should you consider using a classic load balancer instead of an ALB or NLB in AWS?

A classic load balancer should be considered when you have a simple load balancing scenario that does not require advanced routing or content-based routing capabilities, or when you are running an EC2-Classic network.

What is the difference between failover and failback procedures in the context of load balancing?

Failover is the process of switching to a backup system or component when the primary system fails. Failback is the process of returning to the primary system once it has been restored. In load balancing, failover ensures continuous operation, while failback ensures restoration to the original traffic pattern once conditions allow.

How can weight-based load balancing be utilized in AWS, and what are its advantages?

Weight-based load balancing allows assigning different weights to instances, so that instances with higher weights receive a larger proportion of requests. This can be used for directing more traffic to higher-capacity instances or gradually shifting traffic when deploying a new application version (also known as a blue/green deployment).

Can you explain the concept of connection draining in AWS load balancers, and why is it important?

Connection draining, also known as deregistration delay, is a feature that allows existing connections to an instance to complete before the instance is deregistered or shut down. This ensures a graceful shutdown and helps prevent disrupting active user sessions, which is crucial for maintaining a good user experience.

0 0 votes
Article Rating
Subscribe
Notify of
guest
35 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Claudia Ruiz
5 months ago

Great post on load balancing and traffic distribution patterns! Very helpful for the AWS Certified Advanced Networking exam.

Alyssa Blanchard
6 months ago

Thanks for the information. Load balancing was always confusing for me, but this clears up a lot.

Tallak Nordtveit
6 months ago

Can someone explain the difference between Application Load Balancer and Network Load Balancer in simple terms?

Eduardo Grant
5 months ago

Sure! Application Load Balancer operates at Layer 7 (HTTP/HTTPS) and is good for web applications. Network Load Balancer works at Layer 4 (TCP/UDP) and is best for high-performance or latency-sensitive applications.

Arnav Chavare
5 months ago

I appreciate the detailed examples in this post!

Emil Lassila
5 months ago

Not bad, but I feel the post lacks depth in discussing Route 53 traffic policies.

Kiara Faure
5 months ago

Can I use both Application Load Balancer and Network Load Balancer together?

Lynn Cox
5 months ago
Reply to  Kiara Faure

Yes, you can. For instance, you could use an ALB for HTTP traffic and an NLB for TCP traffic in the same application.

Paige Baker
6 months ago

The diagrams were very useful for visualizing how load balancing works.

Indigo Biersteker
5 months ago

How does latency-based routing work with AWS Route 53?

Patsy Payne
5 months ago

Latency-based routing allows Route 53 to route the user to the closest AWS region in terms of latency. This improves the user experience.

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