Load Balancing
Published in
2 min readApr 4, 2018
What is Load Balancing?
A method for distributing tasks on to multiple machines.
Purpose
- To scale horizontally, distributing the work load of an application on to multiple machines
- To make the application more fault-tolerant
- Allows for failover, when one server fails the load balancer removes that server from the cluster and divides the load onto the functioning servers
Different Load Balancing Techniques
Round Robin (Even Task Distribution)
- Used when all servers have the same capacity and all incoming tasks require the same about of work
- For instance if you have 2 servers, then the 1st task would go to the 1st server and the 2nd task would go to the 2nd server, then the 3rd task would go to the 1st server because the 2nd one just got a task
Weighted Round Robin (Weighted Task Distribution)
- Used when servers don’t have the same capacity and the incoming tasks are different
- You specify weights for each server beforehand, it can be based on capacity, power, or the importance of each server, etc.
Sticky Session
- Used when servers rely on each other for values (session state values)
- Instead of distributing tasks, sessions are distributed among different servers
Least Connections (Even Size Task Queue Distribution)
- Load balancer has a task queue* for each server, and it makes sure that each queue has an equal amount of tasks in progress
*Task Queue: Contains all the requests that each server is working on
- Takes the work each task requires and the capacity into account when distributing tasks
Autonomous Queue
- There’s no load balancer, just a task queue
- The task queue doesn’t need to know about the servers, but the servers need to know about the task queues
- If a server wants a task it needs to connect to the queue and download the task