Elastic Load Balancer (ELB)

Elastic Load Balancer (ELB)

·

12 min read

● ELB Stands for Elastic Load Balancer.

● An Elastic Load Balancer (ELB) is a managed AWS service that automatically distributes incoming application traffic across multiple targets, such as Amazon EC2 instances, containers, or IP addresses

● It provides high availability, scaling, and security for the application.

● It spans single or multiple availability zones.

● AWS takes care of upgrades, maintenance

● Spreads load across multiple downstream instances

● Exposes a single point of access (DNS) to your application

● Does regular health checks to your instances

● High availability across zones

● Separates public traffic from private traffic

● Provide SSL termination (HTTPS) for your websites

Types of Elastic Load Balancer Application

Application Load Balancer (ALB):

Keywords: It is best suited for load balancing of web applications and websites.

ALB operates at the application layer (Layer 7) of the OSI model, making routing decisions based on content, such as HTTP/HTTPS requests. It supports advanced features like content-based routing, host-based routing, and containerized applications.

  • Layer 7 (Application Layer) Load Balancer: ALB operates at the application layer of the OSI model, allowing it to intelligently route traffic based on content.

  • Advanced Routing: ALB offers advanced routing capabilities, such as path-based routing and host-based routing. This means you can direct traffic to different services or containers based on URL paths or hostnames.

  • Enhanced HTTP/HTTPS Support: It's optimized for handling HTTP/HTTPS traffic and is well-suited for modern applications that require flexible routing and support for containerized environments.

  • Integration with AWS Services: ALB integrates seamlessly with various AWS services, including AWS WAF (Web Application Firewall) for enhanced security measures at the application layer.

Network Load Balancer (NLB):

Keywords: It is mostly for application which has ultra-high performance.

NLB operates at the transport layer (Layer 4) of the OSI model, making routing decisions based on IP protocol data. It is optimized to handle extremely high volumes of traffic and is ideal for scenarios requiring ultra-low latency.

NLB is suitable for scenarios that require extreme performance, high throughput, and low latency, such as gaming applications and real-time streaming.

The listener checks the connection request from the clients using the protocol and ports we specify. It supports TCP, UDP, and TLS protocols.

  • Layer 4 (Transport Layer) Load Balancer: NLB operates at the transport layer of the OSI model, handling traffic based on IP protocols, ports, and addresses.

  • Ultra-High Performance: NLB is designed for extreme performance and scalability, capable of handling millions of requests per second with ultra-low latencies. This makes it suitable for high-throughput workloads.

  • TCP, UDP, and TLS Traffic Handling: NLB efficiently manages TCP, UDP, and TLS traffic, making it ideal for scenarios where raw performance and low latency are critical.

  • Static IP Address: NLB provides a static IP address, which remains constant even if the underlying resources change. This feature is valuable for applications that depend on fixed IP addresses.

Gateway Load Balancer (GWLB)-Newly Introduced

Keywords: This provides load balancing and auto-scaling for the fleet of third-party appliances. It is used for security, network analytics, and similar use cases.

  • Gateway Load Balancer for Virtual Appliances: GWLB is designed to manage and route traffic to virtual appliances deployed in your VPC (Virtual Private Cloud) for specific use cases like firewall, intrusion detection, and other network appliances.

  • Support for Third-Party Network Appliances: GWLB allows you to deploy and manage third-party virtual appliances, enabling them to scale and handle traffic effectively.

  • Simplified Scalability and Management: It simplifies the deployment and scaling of virtual appliances while providing high availability and fault tolerance.

Classic Load Balancer (CLB):

Keywords: This is the traditional load balancer provided by AWS. It distributes traffic across multiple EC2 instances in multiple Availability Zones.

AWS recommends using an application or Network Load Balancer instead.

  • Legacy Load Balancer: CLB is the older version of Elastic Load Balancer and is being gradually replaced by ALB and NLB.

  • Basic Load Balancing: It provides basic load balancing across multiple Amazon EC2 instances and operates at both the application and transport layers.

  • Less Feature-Rich: Compared to ALB and NLB, CLB offers fewer advanced features and might not be as suitable for modern, complex applications.

Use Cases of ELB

Web Application Deployed in Multiple Servers: If a web Application/Website is deployed in multiple EC2 Instances then we can distribute the traffic between the Application Load Balancers.

Building a Hybrid Cloud: Elastic Load Balancing offers the ability to load balance across AWS and on-premises resources, using a single load balancer. You can achieve this by registering all of your resources to the same target group and associating the target group with a load balancer.

Migrating to AWS: ELB supports the load balancing capabilities critical for you to migrate to AWS. ELB is well positioned to load balance both traditional as well as cloud-native applications with auto-scaling capabilities that eliminate the guesswork in capacity planning.

Cross-Zone Load Balancing

Cross-zone load balancing is a feature that evenly distributes traffic across all registered targets in all availability zones, helping to achieve even distribution and better resource utilization.

When cross-zone load balancing is enabled:

• Each load balancer node distributes traffic across the registered targets in all enabled Availability Zones

When cross-zone load balancing is disabled:

• Each load balancer node distributes traffic only across the registered targets in its Availability Zone

• With Application Load Balancers, cross-zone load balancing is always enabled

• With Network Load Balancers and Gateway Load Balancers, cross-zone load balancing is disabled by default

Implementing ELB: Best Practices

Design for Redundancy and Fault Tolerance

  • Distribute your applications across multiple availability zones to ensure redundancy and fault tolerance.

  • Utilize ELB's cross-zone load balancing feature to evenly distribute traffic across instances in different availability zones.

Leverage Health Checks and auto-scaling

  • Configure health checks to regularly monitor the health of your targets. ELB automatically reroutes traffic away from unhealthy instances.

  • Integrate ELB with Auto Scaling to dynamically adjust the capacity of your instances based on traffic demands.

Optimize for Performance

  • Choose the appropriate type of ELB based on your application's traffic patterns and requirements. For HTTP/HTTPS traffic, ALB might be more suitable, while NLB excels in handling high-throughput scenarios.

  • Utilize features like connection draining and idle timeout settings to manage connections effectively.

Implement Security Measures

  • Employ SSL/TLS certificates to encrypt traffic between clients and the load balancer.

  • Leverage security groups and network ACLs to control inbound and outbound traffic to and from the load balancer.

Monitor and Analyze

  • Utilize AWS CloudWatch metrics to monitor ELB performance and set up alarms for critical metrics such as latency, error rates, and request counts.

  • Consider integrating ELB access logs with Amazon S3 and Amazon Athena for in-depth analysis and insights into traffic patterns.

Some Important Questions!!

What are the differences between Route 53 and ELB?

Amazon Route 53 will handle DNS servers. Route 53 gives you a web interface through which the DNS can be managed using Route 53, it is possible to direct and failover traffic. This can be achieved by using the DNS Routing Policy. One more routing policy is the Failover Routing policy. we set up a health check to monitor your application endpoints. If one of the endpoints is not available, Route 53 will automatically forward the traffic to another endpoint.

ELB automatically scales depending on the demand, so the sizing of the load balancers to handle more traffic effectively when it is not required.

What are AWS Elastic Load Balancing (ELB), and how does it contribute to high availability and scalability in a DevOps environment?

An Elastic Load Balancer (ELB) is a managed AWS service that automatically distributes incoming application traffic across multiple targets, such as Amazon EC2 instances, containers, or IP addresses. It contributes to high availability and scalability in DevOps environments by distributing traffic, ensuring fault tolerance, and optimizing resource utilization.

What are the three types of Elastic Load Balancers available in AWS?

There are three types of Elastic Load Balancers: Application Load Balancer (ALB), Network Load Balancer (NLB), and Gateway Load Balancer (GWLB).

How can you create and configure an Elastic Load Balancer in AWS, and what are the key parameters you need to define during setup?

You can create an ELB using the AWS Management Console, AWS CLI, or CloudFormation. During setup, you define parameters such as the listener configuration, target groups, security groups, and optionally, the routing rules for an ALB.

What is the purpose of health checks in Elastic Load Balancers, and how do they help ensure the availability of application instances?

Health checks are used to monitor the health of registered targets (e.g., instances or containers). ELBs periodically check the health of targets based on the defined health check settings and route traffic only to healthy targets, ensuring application availability.

What is the main difference between Application Load Balancer (ALB) and Network Load Balancer (NLB)?

ALB operates at the application layer and supports advanced routing, including content-based routing and path-based routing. NLB operates at the transport layer and provides ultra-low latency and high throughput.

What are some key features of Application Load Balancer (ALB)?

ALB supports features like dynamic port mapping, path-based routing, support for HTTP/2 and WebSocket protocols, and content-based routing using listeners and rules.

When should you use Network Load Balancer (NLB)?

NLB is suitable for scenarios that require extreme performance, high throughput, and low latency, such as gaming applications and real-time streaming.

What is a target group in Elastic Load Balancing?

A target group is a logical grouping of targets (such as EC2 instances) registered with a load balancer. ALB and NLB use target groups to route requests to registered targets.

How does health checking work in Elastic Load Balancers?

Elastic Load Balancers perform health checks on registered targets to ensure they are available to receive traffic. Unhealthy targets are temporarily removed from rotation.

How can you route requests to different target groups based on URL paths in the Application Load Balancer (ALB)?

ALB supports path-based routing, where you define listeners and rules to route requests to different target groups based on specific URL paths.

How can you configure path-based routing with an Application Load Balancer (ALB), and what are the typical use cases for this feature?

Path-based routing in ALBs allows you to route traffic to different target groups based on the path of the URL. Typical use cases include hosting multiple applications on a single ALB or deploying microservices that share a single ALB.

What is cross-zone load balancing?

Cross-zone load balancing is a feature that evenly distributes traffic across all registered targets in all availability zones, helping to achieve even distribution and better resource utilization.

How can you ensure the security of Elastic Load Balancers, and what are the best practices for configuring security groups and access control?

Best practices for ELB security include using security groups to restrict access to your load balancer and back-end instances, enabling encryption using SSL/TLS, and using Web Application Firewall (WAF) for advanced security features.

Explain the use of AWS Auto Scaling with Elastic Load Balancers and how they work together to provide dynamic scaling for applications.

AWS Auto Scaling and ELBs work together by automatically adding or removing instances based on defined scaling policies. When the load on your application increases, Auto Scaling adds instances, and ELB ensures that traffic is evenly distributed to them.

What are the cost factors to consider when using Elastic Load Balancers, and how can you optimize costs while ensuring high availability and performance?

Cost factors include the number of load balancers, data transfer, and hourly usage. To optimize costs, you can consolidate multiple services on a single ALB, implement intelligent routing, and use Auto Scaling to adapt to traffic fluctuations.

Explain how you can set up monitoring and logging for Elastic Load Balancers using AWS CloudWatch, and what metrics and insights can be obtained from ELB logs.

You can set up monitoring and logging using CloudWatch to track metrics like request counts, latency, and error rates. ELB logs provide detailed information about request traffic and can be analyzed to gain insights into application performance.

How can you enable SSL/TLS encryption for traffic between clients and the load balancer?

You can configure an SSL/TLS certificate on the load balancer, enabling it to terminate SSL/TLS connections and communicate with registered targets over HTTP.

Can you use Elastic Load Balancer (ELB) with resources outside AWS?

Yes, ELB can be used with on-premises resources using Network Load Balancer with IP addresses as targets or with AWS Global Accelerator to route traffic to resources outside AWS.

What is a sticky session, and how can you enable it in Elastic Load Balancers?

Sticky sessions ensure that a user's session is consistently directed to the same target. In ALB, you can enable sticky sessions using the stickiness option in the target group settings.

What is the purpose of pre-warming in Elastic Load Balancers?

Pre-warming involves sending a low volume of traffic to a new load balancer to allow it to scale up its capacity and establish connections gradually.

How does Elastic Load Balancer support IPv6?

Elastic Load Balancer (ALB and NLB) supports both IPv4 and IPv6 addresses, allowing applications to be accessed over the IPv6 protocol.

What is connection draining, and when is it useful?

Connection draining is the process of gradually stopping traffic to an unhealthy target instance before removing it from the target group. It's useful to ensure active requests are completed before taking the instance out of rotation.

How can you enable access logs for Elastic Load Balancers?

You can enable access logs for Elastic Load Balancers to capture detailed information about requests, responses, and client IP addresses. These logs can be stored in an Amazon S3 bucket.

What is the purpose of an idle timeout setting in Elastic Load Balancers?

The idle timeout setting defines the maximum time an idle connection can remain open between the load balancer and a client. After this duration, the connection is closed.

Can you associate Elastic IP addresses with Elastic Load Balancers?

No, Elastic Load Balancers do not have static IP addresses. They have DNS names that are used to route traffic to registered targets.

How can you configure health checks for targets in Elastic Load Balancers?

You can configure health checks by defining a health check path, interval, timeout, and thresholds. ELB sends periodic requests to targets to verify their health.

Can you use Elastic Load Balancers to distribute traffic across regions?

Elastic Load Balancers can distribute traffic only within the same region. For distributing traffic across regions, you can use AWS Global Accelerator.