A quick recap of previous blog, so a Load balancer is used to improve system's availability and responsiveness and also prevents server overload. It does not send request to servers that are already busy. You can relate it with the traffic police, as it sends requests to the right server to avoid bottleneck.
Algorithms
A load balancing algorithm is the set of rules that helps load balancer to identify the best server that will process an incoming request.
It is further categorized into two:
Static load balancing
It follows some strict rules and are independent of the current state of the server. Some examples are:
Round-robin method :
Servers have IP addresses that tells the client where to send the messages. IP addresses are unique and range from 0-255 (ex - 0.167.98.125). These are difficult for humans to remember. Therefore, DNS (Domain Name System) maps websites names to servers, which returns IP address to the browser.
In round-robin, the load balancing is done by name server instead of any hardware or software, which returns the IP addresses in a round-robin fashion.
Weighted Round-robin method:
In this method, each servers are assigned some weights or priorities and based on that servers will get requests from the name server. In laymen term, high priority server will get more incoming traffic and vice versa.
IP hash :
In this method, a mathematical calculation is performed. The IP addresses will be converted into some number using hashing which will be mapped to the respective servers.
Dynamic Load Balancing
In dynamic load balancing, the server's current state will be determined before passing the request or traffic. Some examples are:
Least connection method:
A connection is a open channel between client and server to communicate. When the client sends request, then a connection between client and server is established. In least connection method, the load balancer will check if the server have few active connections and if it is then it will send traffic to that server.
Weighted Least connection method:
Here, it is just like weighted round-robin. It assumes that some server can handle more requests and so it assigns some weights to each server.
Least Response Time:
Load balancer use this method to provide faster service to the clients. The response time is the total time that the server takes to process the requests and send a response. Therefore, least response time checks the server response time and all active connections to determine the best server.
Note: There are many more algorithms but these are some most commonly used. In the next blog, we will see types of load balancers.