AWS ELB (Elastic Load Balancing)

AWS ELB (Elastic Load Balancing)

Optimizing Traffic Flow for High Availability

Codefy Labs's photo
Jun 9, 2024·

4 min read

AWS Elastic Load Balancing (ELB) seamlessly manages the distribution of incoming application traffic across multiple targets, including EC2 instances, containers, and IP addresses. This essential service not only enhances fault tolerance and ensures high availability but also supports scalability. In this post, we'll explore the key features of ELB, examine its various types, and provide a hands-on example to illustrate its capabilities.

Introduction to ELB

Elastic Load Balancing is adept at automatically adjusting to changes in incoming traffic, ensuring that loads are evenly distributed across multiple availability zones. This functionality is crucial for maintaining the robustness and uninterrupted availability of your applications. By routing traffic only to healthy endpoints, ELB enhances the overall efficiency and reliability of your application infrastructure.

Key Components Explained

  • Load Balancer: Routes incoming traffic to various targets to manage load efficiently.

  • Target Group: Groups together targets like EC2 instances, specifying how traffic should be routed to them.

  • Target: Receives incoming traffic from the load balancer. These are typically EC2 instances or IP addresses.

  • Listener: Listens for incoming traffic and directs it to the appropriate targets based on defined rules.

  • Availability Zones: Data centers that provide redundancy in power, networking, and cooling to ensure continuous availability.

Types of Elastic Load Balancers

AWS offers several types of Elastic Load Balancers, each tailored to meet different needs:

  • Application Load Balancer (ALB): Specifically designed for HTTP and HTTPS traffic, the ALB excels in advanced request routing, making it ideal for modern web applications. It supports complex routing algorithms, such as host-based and path-based routing, and integrates smoothly with microservices and container-based architectures.

  • Network Load Balancer (NLB): Optimized for low latency and high throughput scenarios, the NLB is best suited for TCP, UDP, and TLS traffic. This makes it an excellent choice for applications requiring real-time data and streaming, such as gaming and IoT applications.

  • Classic Load Balancer (CLB): As the original type of Elastic Load Balancer, the CLB provides basic load balancing across multiple Amazon EC2 instances. While it is less feature-rich than its newer counterparts, it is still effective for applications that have simple load-balancing needs or for those transitioning from traditional architectures.

    Lab Session: Set Up an Application Load Balancer

    Let's proceed with a practical exercise by setting up an Application Load Balancer and attaching it to an Auto Scaling group of EC2 instances. This step is crucial for our high availability project, ensuring that our application remains robust and responsive under varying loads.

    To create a load balancer, navigate to the EC2 dashboard, select 'Load Balancers' from the sidebar, and then click on 'Create Load Balancer'.

    Now, select 'Application Load Balancer'

    Enter a name for your load balancer and set the scheme to 'internet-facing'

    For “Availability Zones”, choose the zones where your EC2 instances are located. Select the VPC that was previously set up for our high availability project. If you need guidance on creating a VPC, you can follow this detailed tutorial: How to Create a VPC in AWS. After selecting the VPC, also choose the corresponding availability zones and public subnets.

    Select your security group

    • configure the security group and set the inbound rules.

In the listener settings, create and select a target group.

  • For basic target group configuration, include these steps:

    1. Name: Assign a descriptive name to your target group.

    2. Target Type: Choose between instances, IP addresses, or Lambda functions.

    3. VPC Selection: Select the VPC that contains your target resources.

    4. Health Check Path: Specify the path that the load balancer should use to perform health checks on the targets.

Note*: Do not add targets at this stage as the Auto Scaling group will automatically register and deregister instances based on demand and health status. If not using an Auto Scaling group, manually add EC2 instances to your target group at this stage.*

Complete the creation process

Conclusion

AWS Elastic Load Balancing is an essential tool for ensuring high availability and fault tolerance in applications. Its ability to adapt to different traffic patterns and its variety of load balancer types make it a critical component of any robust AWS-based architecture.