Distributing Your Application Traffic: The AWSome Way!
Tags: aws, loadbalancers
Published: 2023-07-09 04:43:13

Load balancing involves evenly distributing incoming data traffic among a group of backend computers, often referred to as a server pool or server farm.

In order to effectively handle a large volume of concurrent user or client requests, high-traffic websites must consistently deliver accurate text, photos, multimedia, and application programs. To follow best practices in digital computing, it is often necessary to add additional servers in a cost-effective manner to handle these high loads.

A load balancer acts as a "traffic officer" positioned alongside the servers. It directs customer requests to all the web servers capable of satisfying those requests, optimizing efficiency and ensuring resilience. This approach prevents any single server from being overloaded, which could potentially degrade its performance.

In the event of a server failure, the load balancer automatically redirects requests to the remaining functional web servers. Once a server is assigned to a server group, the load balancer begins routing responses to that server.

![How Load Balancers Distribute Traffic](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lttz81ggm2jnjl6v9v2e.png)

Here are a few key reasons why load balancers are essential:

**_Enhanced Performance:_** Load balancers distribute traffic across multiple servers, preventing any single server from being overwhelmed with requests. By evenly distributing the load, they ensure optimal resource utilization and reduce the risk of server congestion, thereby improving the overall performance and responsiveness of applications.

**_High Availability:_** Load balancers play a crucial role in ensuring high availability of applications. If one server becomes unavailable due to hardware failure, maintenance, or any other reason, the load balancer can redirect traffic to other healthy servers, minimizing downtime and providing uninterrupted service to users.

_**Scalability:**_ Load balancers enable horizontal scaling, which means adding more servers to handle increased traffic. As the demand for an application grows, load balancers can distribute the load across the expanded infrastructure, allowing for seamless scalability without affecting the user experience.

_**Fault Tolerance:**_ Load balancers can detect if a server becomes unresponsive or fails and automatically redirect traffic to other healthy servers. This fault tolerance mechanism helps maintain the availability of applications even in the presence of server failures.

**_SSL Termination:_** Load balancers can handle SSL/TLS encryption and decryption, offloading the resource-intensive task from backend servers. This feature improves server performance and simplifies the management of SSL certificates.

_**Traffic Management:**_ Load balancers offer various traffic management capabilities, such as session persistence, content-based routing, and request routing based on server health. These features allow for efficient distribution of traffic based on specific criteria, optimizing resource allocation and providing a better user experience.


### What is Elastic Load Balancer (ELB)?

An Elastic Load Balancer (ELB) is a service provided by AWS that automatically distributes incoming application traffic across multiple resources, such as Amazon EC2 instances, containers, or IP addresses. It acts as a single entry point for clients and efficiently distributes the workload to ensure high availability, scalability, and fault tolerance.

The term "_elastic_" in Elastic Load Balancer refers to its ability to dynamically scale and adapt to changing traffic patterns and resource availability. These are the types of Elastic Load Balancers offered by AWS:

1. Classic Load Balancer (CLB)
2. Application Load Balancer (ALB)
3. Network Load Balancer (NLB)
4. Gateway Load Balancer (GWLB)

![Types of ELB](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hvblpcom8i52wkgz3gwi.png)

**_Classic Load Balancer (CLB):_** The CLB provides basic load balancing capabilities and is suitable for applications that require simple load distribution. It operates at the transport layer (Layer 4) of the OSI model, distributing traffic based on network-level information such as IP addresses and ports.

**_Application Load Balancer (ALB):_** The ALB operates at the application layer (Layer 7) and provides advanced load balancing features. It can intelligently route traffic based on content, such as HTTP headers, URL paths, or request methods. ALB is well-suited for modern web applications with multiple microservices.

**_Network Load Balancer (NLB):_** The NLB operates at the transport layer (Layer 4) and is designed for high-performance, low-latency scenarios. It can handle millions of requests per second while maintaining ultra-low latencies. NLB is suitable for TCP, UDP, and TLS traffic.

**_Gateway Load Balancer (GWLB):_** The GWLB operates at the network layer (Layer 3) and is primarily used for load balancing traffic between Virtual Private Clouds (VPCs), AWS Transit Gateways, and on-premises networks. It offers highly scalable and efficient load balancing capabilities, distributing traffic across multiple endpoints such as Virtual Private Gateways (VGWs) and Network Load Balancers (NLBs). With GWLB, users can achieve advanced traffic management, source IP affinity, and security integration for your network infrastructure. It helps ensure reliable and efficient distribution of network traffic across different environments, enabling high availability and fault tolerance.