Tutorial / Cram Notes

AWS offers various types of load balancers, each tailored to specific use cases. When selecting a load balancer, consideration of various factors such as the application type, traffic pattern, and the need for secure sockets layer (SSL) offloading is crucial.

The main types of load balancers on AWS are:

  • Classic Load Balancer (CLB)
  • Application Load Balancer (ALB)
  • Network Load Balancer (NLB)

Here is a comparison of their core features:

Feature Classic Load Balancer (CLB) Application Load Balancer (ALB) Network Load Balancer (NLB)
Protocols Supported HTTP, HTTPS, TCP, SSL HTTP, HTTPS, WebSocket, HTTP/2 TCP, TLS, UDP, TCP_UDP
Performance Good; suitable for small to medium workloads Better; optimized for modern application architectures Best; optimized for high-performance and low-latency needs
Routing Layer 4 (Transport) Layer 7 (Application) Layer 4 (Transport)
Content-Based Routing Not available Supported Not available
SSL/TLS Offloading Supported Supported Supported (using TLS listeners)
Fixed Hostname Yes Yes No (assigned an IP address)
Path-Based Routing Not available Supported Not available
Sticky Sessions Supported Supported Not available
WebSockets Supported via TCP Native support Supported via TCP
High Availability Available with multiple AZ deployment Available with multiple AZ deployment Available with multiple AZ deployment, and static IP or Elastic IP
Health Checks Basic Advanced Basic but high-performance
Containerized Applications Adequate Preferred Adequate

Let’s dive into some examples to illustrate use cases for each type of load balancer:

Classic Load Balancer (CLB):

The Classic Load Balancer is a legacy option that provides basic load balancing at both the transport (Layer 4) and application (Layer 7) layers. It’s suitable for applications that were built within the EC2-Classic network. For instance, if you are running a simple web application that doesn’t require advanced routing features, a CLB could be an appropriate and cost-effective choice.

Application Load Balancer (ALB):

The Application Load Balancer is best suited for HTTP and HTTPS traffic. It provides advanced request routing targeted at modern application architectures, including microservices and containers. For example, if you’ve got an application with several microservices, each running in its own set of containers, ALB can route traffic to the right service using path-based routing. Here’s an example rule that directs traffic for different paths:

IF Path = /user/* THEN forward to UserService
IF Path = /order/* THEN forward to OrderService

ALB also provides native support for WebSocket, which is useful for applications requiring persistent connections, like chat apps or real-time collaboration tools.

Network Load Balancer (NLB):

This load balancer operates at the transport layer and is designed for applications that need high performance and low latency. NLB is ideal for TCP traffic where extreme performance is required. It can handle millions of requests per second while maintaining ultra-low latencies. NLB would be the preferred choice for a financial trading platform, where millisecond improvements in latency could translate to significant business advantage.

Determining the Right Load Balancer:

  • Use Case:

    • Simple Load Balancing: If your needs are basic and you’re balancing simple HTTP or HTTPS traffic, a CLB may suffice.
    • Advanced HTTP Features: Select an ALB if you need advanced features such as content-based routing, HTTPS termination, and WebSocket support.
    • High Performance Non-HTTP: Choose an NLB if you require high throughput for non-HTTP based applications or need static IP addresses for your load balancer.
  • Performance: Evaluate the expected traffic levels. For higher performance needs, especially when low latency is a concern, NLB is likely the best option.
  • Targets: Determine whether your targets are EC2 instances, microservices, or containers. ALBs are built to accommodate the dynamic nature of microservices and container-based applications.

In summary, when selecting a load balancer on AWS, it’s important to carefully consider the nature of your applications, the protocols they use, the performance they require, and the level of control you need over traffic distribution. By weighing these factors against the features offered by each type of load balancer, you can select the most appropriate solution for your specific use case. Always refer to the most current AWS documentation for any updates or changes to the services and features as they evolve rapidly.

Practice Test with Explanation

True or False: Amazon Route 53 can be used as a global load balancer.

  • True
  • False

True

Amazon Route 53 provides DNS level load balancing and routing which can be used to distribute traffic globally across multiple endpoints.

Which AWS load balancer type is best suited for containerized applications?

  • Application Load Balancer (ALB)
  • Network Load Balancer (NLB)
  • Classic Load Balancer (CLB)
  • AWS Global Accelerator

Application Load Balancer (ALB)

Application Load Balancer provides advanced request routing targeted at modern application architectures, including microservices and containers.

When needing to maintain a source IP address for client requests, which load balancer should you choose?

  • Application Load Balancer
  • Network Load Balancer
  • Classic Load Balancer
  • Both A and C

Network Load Balancer

Network Load Balancer preserves the client-side source IP allowing the back-end to see the IP address of the client.

True or False: A Classic Load Balancer is the best choice for low-latency, high-throughput applications that require UDP traffic support.

  • True
  • False

False

The Network Load Balancer is designed for high-throughput, low-latency applications and provides support for both TCP and UDP traffic.

Which load balancer supports path-based routing?

  • Application Load Balancer
  • Network Load Balancer
  • Classic Load Balancer
  • All of the above

Application Load Balancer

Application Load Balancer supports advanced request routing, which includes path-based routing, allowing different paths to be routed to different target groups.

For a multi-region, latency-sensitive application, which solution can improve performance?

  • AWS Global Accelerator
  • Application Load Balancer
  • Classic Load Balancer
  • Network Load Balancer

AWS Global Accelerator

AWS Global Accelerator improves performance by using AWS’s global network infrastructure to route user’s traffic to the nearest regional endpoint.

True or False: Application Load Balancers can route traffic to multiple ports on a single EC2 instance.

  • True
  • False

True

Application Load Balancer allows routing of traffic to multiple ports on the same EC2 instance, which is useful for container-based applications.

In which scenario should you use a stickiness feature on your load balancer?

  • Stateless applications
  • Stateful applications
  • When using HTTP/2
  • When load balancing UDP traffic

Stateful applications

Stickiness is used to ensure that requests from a particular client are directed to the same target for the session’s duration, which is necessary for stateful applications.

When distributing traffic to applications hosted in multiple Availability Zones, which AWS service automatically provides a failover feature?

  • AWS Global Accelerator
  • Amazon Route 53
  • Application Load Balancer
  • Network Load Balancer

Amazon Route 53

Amazon Route 53 can automatically route traffic to multiple applications in different Availability Zones, providing high availability and failover support.

True or False: You can use an AWS Load Balancer to route traffic to on-premises servers.

  • True
  • False

True

AWS Load Balancers can route traffic to targets within a VPC or on-premises servers, assuming there is appropriate network connectivity, like VPN or AWS Direct Connect.

Which AWS load balancer should you use if you need WebSocket support?

  • Application Load Balancer
  • Network Load Balancer
  • Classic Load Balancer
  • Both A and C

Application Load Balancer

Application Load Balancer provides native support for WebSocket, which is a protocol providing full-duplex communication channels over a single TCP connection.

Which AWS load balancer is able to handle volatile workloads and millions of requests per second with low latencies?

  • Application Load Balancer
  • Network Load Balancer
  • Classic Load Balancer
  • Both A and B

Network Load Balancer

Network Load Balancer is optimized to handle volatile workloads and very high levels of traffic with very low latencies. It’s capable of handling millions of requests per second after a brief ramp-up time.

Interview Questions

What are the different types of load balancers offered by AWS, and how do they differ?

AWS offers three types of load balancers: the Classic Load Balancer (CLB), the Network Load Balancer (NLB), and the Application Load Balancer (ALB). CLB is suitable for simple load balancing of traffic across EC2 instances. NLB is best for load balancing TCP traffic where extreme performance is required. ALB is optimal for application-level load balancing that requires HTTP/HTTPS routing based on content.

How does the choice of a load balancer affect the scalability and availability of an application in AWS?

The choice of a load balancer directly impacts the scalability and availability since each type has different performance characteristics. ALBs are ideal for microservices and container-based applications and support dynamic host port mapping, while NLBs handle millions of requests per second with ultra-low latencies, enabling scalability. CLBs are less flexible compared to ALBs and NLBs.

When would you choose a Network Load Balancer over an Application Load Balancer?

You would choose an NLB over an ALB when you need ultra-high performance, static IP or Elastic IP for your load balancer, or when dealing with TCP, UDP, or TLS (Layer 4) traffic that doesn’t require the advanced routing capabilities of an ALB.

Can you explain how AWS’s Global Accelerator can work in conjunction with load balancing to improve global application performance?

AWS Global Accelerator complements AWS load balancers by directing users to the nearest application endpoint using AWS’s global network infrastructure, which improves performance and reduces internet latency and jitter. It’s optimal for international applications where users are distributed across different regions.

What considerations would lead you to recommend the use of cross-zone load balancing?

You would recommend cross-zone load balancing when you want to ensure even traffic distribution across all instances in multiple availability zones, preventing unequal load distribution that could lead to instances in one zone being over-utilized while others are under-utilized.

How would you determine whether to enable sticky sessions on your load balancer?

Sticky sessions should be enabled when your application needs to maintain a user session on a specific backend instance. If the application doesn’t store state information locally or session persistence isn’t necessary for user experience, then sticky sessions would not be required.

Explain how AWS Certificate Manager (ACM) integrates with AWS load balancers for SSL/TLS management?

ACM integrates with AWS load balancers by allowing you to provision, manage, and deploy SSL/TLS certificates on your ALB or NLB. The load balancer uses these certificates to encrypt traffic between clients and the load balancer, simplifying certificate management and ensuring secure communication.

When should you consider using a Classic Load Balancer instead of more recent offerings like Network or Application Load Balancer?

You should consider using a CLB when you have an existing application running within the EC2-Classic network or if you require simple round-robin routing without the need for advanced routing or content-based routing capabilities.

What role does an AWS load balancer’s health check play in ensuring application reliability?

Health checks allow the load balancer to automatically check the health of the EC2 instances. If an instance is deemed unhealthy, the load balancer stops sending traffic to it and reroutes traffic to healthy instances. This ensures application reliability by preventing requests from being sent to failing or overburdened servers.

Can you describe scenarios where a combination of different AWS load balancers might be the most effective solution?

A combination of different AWS load balancers might be most effective in a microservices architecture where an ALB is used to route HTTP/HTTPS traffic to different services, and within those services, an NLB is used to route TCP or UDP traffic to individual microservices or containers. This provides both application-level routing and high-performance traffic management.

How do path-based routing options in an Application Load Balancer influence application architecture decisions?

Path-based routing in an ALB influences architecture decisions by allowing the segregation of traffic based on URL paths to different back-end services, enabling a more microservices-oriented architecture with cleaner separation of concerns and potentially reducing the complexity of service discovery and routing logic within the application code.

What metrics would you monitor to assess the performance of your chosen AWS load balancer, and why?

Key metrics to monitor include request count, request latency, the number of healthy/unhealthy hosts, HTTP response codes, and backend connection errors. Monitoring these metrics helps assess the load balancer’s performance and the health of the underlying resources, ensuring that any issues can be quickly identified and resolved to maintain application performance and reliability.

0 0 votes
Article Rating
Subscribe
Notify of
guest
27 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Bratislav Polić
6 months ago

Great post! This helps a lot in understanding which load balancer to choose for different scenarios.

Ronnie Johnston
6 months ago

This blog post is very informative! Helped me understand the nuances of choosing the right load balancer for my use case.

Aron Fogaça
7 months ago

Can someone explain when it’s more appropriate to use Application Load Balancer (ALB) over Network Load Balancer (NLB)?

Hildegard Aubert
6 months ago

What are the main differences between ELB and Gateway Load Balancer?

Darryl Roberts
7 months ago

Thanks for this post, it clarified a lot of my doubts.

Mathis Roy
7 months ago

Why is latency a concern when choosing a load balancer?

Donato Mercier
6 months ago

Good post! Helped a lot.

Samantha Hicks
7 months ago

I found the section on cost-effectiveness really helpful, thanks!

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