What is a Load Balancer?

What is a Load Balancer?

Load Balancers Decoded: A Beginner-Friendly Overview

Introduction

A load balancer is a crucial component in a distributed computing as it distributes the incoming load across multiple servers. The primary purpose of load balancer is to ensure that a single server does not get flooded with multiple requests, preventing downtime and performance degradation.

How Load Balancers Work?

  1. When a user sends a request to access a website or an application, the request first reaches the load balancer.

  2. The load balancer manages a pool of servers aka nodes capable of handling the incoming requests. These servers host the application or website.

  3. The load balancer uses a specific algorithm to decide which server from the pool should handle the incoming request.

  4. The selected server is then assigned the task of fulfilling the user request and load balancer forwards the request to the chosen server.

  5. The selected server processes and generates a response and sends it back to the user through the load balancer.

Types of Load Balancer

  1. Physical Load Balancer: Physical devices dedicated to balancing traffic. They often provide high performance.

  2. Software Load Balancer: Implemented as software solutions and can be run on standard server hardware. These are easier to scale than physical load balancer.

  3. Layer 4(Transport Layer) Load Balancer: Operates at the transport layer of the OSI Model and makes decision based on the network-level information such as IP addresses and ports. It just acts like a firewall.

  4. Layer 7(Application Layer) Load Balancer: Operates at the application layer of the OSI Model and makes routing decision based on the content which allows for more advanced load balancing decisions.

Load Balancing Algorithms

  1. Round Robin: Distributes load equally among all the available servers. Each server gets a turn to handle a request.

  2. Least Connection: Directs the traffic to the server with the least active connections. This helps loads more evenly.

  3. Least Response Time: Directs the traffic to the server with the least response time. This can help minimize latency.

  4. IP Hash: Uses a hash of client's IP address to determine which server will handle the request. This ensures that request from the same IP address always go to the same server.

  5. Random: Select a random server to handle each request but it may not guarantee an even distribution of load.

  6. Weighted Round Robin: Similar to Round Robin, but servers are assigned weights. More the weight more will be the requests handle by it.

  7. Weighted Least Connections: Similar to Least Connection, but servers are assigned weights. More the weight less will be the requests handled by it.

  8. Adaptive Load Balancing: Adjusts the load balancing algorithm based on the server's load or performance.

💡
Follow For More !

Did you find this article valuable?

Support Suvesh's Blog by becoming a sponsor. Any amount is appreciated!