What is Load balancing algorithms ?
Load balancing algorithms are methods used to distribute incoming network traffic or workloads across multiple servers or resources to ensure that no single server becomes overwhelmed. The goal is to optimize resource use, maximize throughput, minimize response time, and avoid overload on any single resource.

Overview – Random and Weighted Random Algorithms
The Random and Weighted Random algorithms are load balancing techniques that distribute client requests across servers based on random selection. These methods can be particularly useful in scenarios where simple and efficient load distribution is required without the need for complex monitoring or calculations.
Random and Weighted Random Algorithms
Random Algorithm
How It Works
- Server List: The load balancer maintains a list of all available servers.
- Random Selection: For each incoming request, the load balancer selects a server from the list at random.
- Request Routing: The request is routed to the randomly selected server.
- Continuity: This process continues for each new request, ensuring a simple and fair distribution.
Detailed Example
Consider a scenario with three servers: Server A, Server B, and Server C. Incoming requests are distributed as follows:
- Request 1 -> Random selection -> Server B
- Request 2 -> Random selection -> Server A
- Request 3 -> Random selection -> Server C
- Request 4 -> Random selection -> Server A
Each request is assigned to a server purely based on random selection, without considering any previous requests or server load.
Advantages
- Simplicity: Easy to implement and understand, with no need for complex logic or monitoring.
- Even Distribution: Over a large number of requests, random selection tends to distribute the load evenly across servers.
- Low Overhead: Minimal computational overhead since the selection is based purely on randomness.
Disadvantages
- Lack of Load Awareness: Does not consider the current load or capacity of servers, which can lead to inefficiencies if some servers are more powerful or less loaded than others.
- Short-Term Imbalances: In the short term, random selection can lead to uneven distribution of requests, though this tends to balance out over time.
- No Session Persistence: Requests from the same client may be directed to different servers, which can be problematic for applications requiring session persistence.
Random and Weighted Random Algorithms
Weighted Random Algorithm
How It Works
- Server List with Weights: The load balancer maintains a list of servers, each assigned a specific weight based on its capacity or performance characteristics.
- Weight-Based Random Selection: For each incoming request, the load balancer selects a server at random, but the selection is influenced by the server weights. Servers with higher weights have a higher probability of being selected.
- Request Routing: The request is routed to the selected server based on the weighted random selection.
- Continuity: This process continues for each new request, ensuring that servers with higher capacities handle more requests.
Detailed Example
Consider a scenario with three servers with different capacities and weights:
- Server A: Weight 5
- Server B: Weight 3
- Server C: Weight 1
The probability of each server being selected is proportional to its weight:
- Server A: 5 / (5+3+1) = 5/9 ≈ 55.6%
- Server B: 3 / (5+3+1) = 3/9 ≈ 33.3%
- Server C: 1 / (5+3+1) = 1/9 ≈ 11.1%
Incoming requests are distributed as follows:
- Request 1 -> Weighted random selection -> Server A
- Request 2 -> Weighted random selection -> Server A
- Request 3 -> Weighted random selection -> Server B
- Request 4 -> Weighted random selection -> Server A
- Request 5 -> Weighted random selection -> Server C
Servers with higher weights, such as Server A, are more likely to be selected, ensuring that they handle a larger share of the workload.
Advantages
- Proportional Load Distribution: Ensures that more powerful servers handle more requests, optimizing resource utilization.
- Adaptability: Easily adapts to different server capacities by adjusting weights, making it suitable for heterogeneous environments.
- Low Overhead: Similar to the basic random algorithm, it incurs minimal computational overhead.
Disadvantages
- Complexity in Weight Assignment: Requires careful assignment of weights to servers, which can be challenging in dynamic environments where server performance varies.
- Short-Term Imbalances: While the weighted random selection tends to balance out over time, short-term imbalances can still occur.
- No Session Persistence: Similar to the basic random algorithm, it does not ensure that requests from the same client are directed to the same server, which can be an issue for certain applications.
Random and Weighted Random Algorithms
Summary – Random and Weighted Random Algorithms
The Random and Weighted Random algorithms are simple yet effective load balancing methods that distribute client requests based on random selection. The basic random algorithm offers simplicity and fairness over a large number of requests but lacks awareness of server load and capacity. The weighted random algorithm addresses this by incorporating server weights, ensuring that more powerful servers handle a proportionately larger share of the workload.
Both algorithms are easy to implement and incur minimal overhead, making them suitable for scenarios where simplicity and low computational cost are priorities. However, they do not provide session persistence and can lead to short-term imbalances, which may require additional mechanisms or enhancements to address in more complex environments.
Useful Links
https://www.a10networks.com/products
https://sanchitgurukul.com/tutorials-cat
Random and Weighted Random Algorithms for Load Balancing: Advantages and Disadvantages
This article provided insights on the topic. For latest updates and detailed guides, stay connected with Sanchit Gurukul.
