- by x32x01 ||
A Load Balancer distributes incoming network traffic across multiple servers instead of sending every request to a single server. This helps prevent server overload, improves application performance, and keeps services available even when individual servers fail.
Load balancing is a key part of modern cloud infrastructure, especially for applications that handle thousands or millions of requests.
The process works like this:
Imagine an application running on three backend servers:
The best algorithm depends on the application, server capacity, and traffic patterns.
Common health check methods include:
Once the failed server becomes healthy again, it can be added back to the available server pool.
1. Classic Load Balancer (CLB)
The older generation of AWS load balancing. Supports basic Layer 4 and Layer 7 load balancing.
2. Application Load Balancer (ALB)
Operates at Layer 7 (Application Layer). Supports content-based routing using HTTP headers, hostnames, URL paths, and other request attributes.
3. Network Load Balancer (NLB)
Operates primarily at Layer 4 (Transport Layer). Designed for high-performance TCP, UDP, and TLS traffic.
4. Gateway Load Balancer (GWLB)
Operates at Layer 3 and helps deploy and scale virtual network appliances, such as firewalls and intrusion detection systems.
Important: A Load Balancer does not automatically guarantee high availability. The backend servers, health checks, network configuration, and Load Balancer deployment must all be designed properly.
In cloud platforms like AWS, Elastic Load Balancing is a managed service designed to distribute traffic across multiple Availability Zones, rather than relying on a single standalone server.
Load balancing is a key part of modern cloud infrastructure, especially for applications that handle thousands or millions of requests.
⚙️ How Does a Load Balancer Work?
A Load Balancer sits between clients and backend servers. When a user sends a request, the Load Balancer receives it and selects an appropriate server based on its configuration, routing algorithm, and server health.The process works like this:
- A client sends a request to the Load Balancer.
- The Load Balancer evaluates available backend servers.
- It selects a server based on the configured algorithm.
- The request is forwarded to that server.
- The server processes the request and returns the response.
Imagine an application running on three backend servers:
- Server 1
- Server 2
- Server 3
🔄 Common Load Balancing Algorithms
A Load Balancer can use different algorithms to decide which server should receive each request.| Algorithm | How It Works |
|---|---|
| Round Robin | Distributes requests sequentially across available servers. |
| Least Connections | Sends new connections to the server with the fewest active connections. |
| Least Response Time | Selects a server based on response time and other supported performance metrics. |
🩺 What Are Health Checks?
Health Checks allow a Load Balancer to monitor backend servers and determine whether they are healthy enough to receive traffic.Common health check methods include:
- HTTP Checks: Send HTTP requests to verify that an application endpoint is responding correctly.
- TCP Checks: Check whether a server accepts connections on a specific port.
Once the failed server becomes healthy again, it can be added back to the available server pool.
🚀 Benefits of Using a Load Balancer
Load balancing provides several important benefits:- Scalability: Distributes traffic across multiple servers and makes it easier to add more capacity.
- High Availability: Helps keep applications accessible when one or more backend servers fail.
- Reliability: Reduces the impact of individual server failures.
- Performance: Prevents traffic from overwhelming a single server.
☁️ Types of Load Balancers in AWS
Amazon Web Services (AWS) provides four main types of Elastic Load Balancers (ELB).1. Classic Load Balancer (CLB)
The older generation of AWS load balancing. Supports basic Layer 4 and Layer 7 load balancing.
2. Application Load Balancer (ALB)
Operates at Layer 7 (Application Layer). Supports content-based routing using HTTP headers, hostnames, URL paths, and other request attributes.
3. Network Load Balancer (NLB)
Operates primarily at Layer 4 (Transport Layer). Designed for high-performance TCP, UDP, and TLS traffic.
4. Gateway Load Balancer (GWLB)
Operates at Layer 3 and helps deploy and scale virtual network appliances, such as firewalls and intrusion detection systems.
📌 Load Balancer vs. a Single Server
| Single Server | Load Balancer |
|---|---|
| Handles all incoming traffic itself. | Distributes traffic across multiple servers. |
| Can become a bottleneck. | Reduces pressure on individual servers. |
| Server failure can interrupt the service. | Can redirect traffic to healthy servers. |
| Scaling may require upgrading one machine. | Supports horizontal scaling by adding servers. |
In cloud platforms like AWS, Elastic Load Balancing is a managed service designed to distribute traffic across multiple Availability Zones, rather than relying on a single standalone server.