Scheduling Algorithms
Static approach: scheduling is achieved only based on the algorithm itself; the starting point is fair, and no matter how many requests the server is currently processing, the same amount is allocated
Dynamic approach: scheduling is achieved based on the algorithm and the current load status of the back-end RS; it doesn't matter how much has been allocated before, and only looks at the result of the allocation Is not fair
static Schedu (static scheduling algorithm) (4 kinds):
(1)rr (Round Robin) :Round Robin, polling
Description: polling scheduling algorithm is the principle of every request from the user is assigned in turn to the internal servers, starting from 1, up to N (number of internal servers), and then restart the cycle. Then the cycle starts again. The advantage of the algorithm is its simplicity, it does not need to record the state of all current connections, so it is a stateless scheduling. Disadvantage: is that it does not take into account the processing power of each server.
(2)wrr (Weight Round Robin) :weighted polling (with the proportion between the weights to achieve scheduling between the hosts)
Description: Due to the configuration of each server, the installation of different business applications, etc., its processing capacity will be different. Therefore, we assign different weights to each server based on its different processing capabilities so that it can accept service requests with the corresponding number of weights.
(3)sh (Source Hashing) : Source address hashing to achieve session binding sessionaffinity
Description: Simply put, there will be the same client's request sent to the same real server, the source address hashing scheduling algorithm is exactly the opposite of the destination address hashing scheduling algorithm, which is based on the source of the request. IP address, as a hash key (Hash Key) from the static allocation of the hash table to find out the corresponding server, if the server is available and not overloaded, the request will be sent to the server, otherwise return empty. It uses the same hash function as the destination address hash scheduling algorithm. Its algorithmic flow is basically similar to that of the destination address hash scheduling algorithm, except that the destination IP address of the request is replaced with the source IP address of the request.
(4)dh : (Destination Hashing) : Destination address hash
Description: the same request is sent to the same server, generally used for caching servers, in short, the LB cluster behind the addition of a layer in the LB and realserver between the addition of a layer of caching servers, when a client When a client requests a page, the LB is sent to cache1, when the second client requests the same page, the LB is still sent to cache1, which is what we said, the same request to the same server, to improve the hit rate of the cache. Target address hash scheduling algorithm is also for the target IP address load balancing, it is a static mapping algorithm, through a hash (hash) function will be a target IP address mapping to a server. The target address hash scheduling algorithm first finds out the corresponding server from the statically assigned hash table based on the requested target IP address as a hash key, and sends the request to the server if it is available and not overloaded, otherwise it returns null.
Dynamic Scheduling Algorithm (dynamic Schedu) (6 types):
(1)lc (Least-Connection Scheduling): least-connection
Description: The least-connection scheduling algorithm assigns new connection requests to the server with the smallest number of current connections. Scheduling short algorithm, which estimates the load balancing of servers by the number of connections they currently have active, the scheduler needs to keep track of the number of established connections for each server, when a request is scheduled to a particular server, its connections are added to one, and when the connection is aborted or times out, its connections are subtracted from one, in the system implementation, we also introduce that when a server's weight is 0, it means that the server is unavailable and is not to be scheduled. This algorithm ignores the problem of server performance, some servers have good performance and some have poor performance, by adding weights to differentiate the performance, so the following algorithm wlc.
Simple Algorithm: active*256+inactive (whoever's small, picks who)
(2)wlc (Weighted Least- Connection Scheduling):Weighted Least-Connection
The weighted least-connection scheduling algorithm is a superset of the least-connection scheduling, where each server expresses its processing performance with a corresponding weight. The default weight of a server is 1. The system administrator can dynamically set the server's privileges. Weighted least-connection scheduling makes the number of established connections to a server as proportional to its weight as possible when scheduling new connections. Because of the different performance of the servers, we give the relatively good performance of the server, increase the weight, that is, it will receive more requests.
Simple algorithm: (active*256+inactive)/weight (whoever's small, pick who)
(3)sed (shortest expected delay scheduling): least expected delay
Explanation: regardless of inactive connections, whoever's weight is large, we give priority to Choose the server with the highest weight to receive requests, but there will be a problem, that is, the server with the higher weight will be busy, but the server with the relatively smaller weight is idle, or even will not receive requests, so the following algorithm nq.
Based on the wlc algorithm, a simple algorithm: (active+1)*256/weight (whoever's the smallest choose who)
((). 4).nq (Never Queue Scheduling): Never Queue
Description: In the above we explained that, due to the weight of a server is small, relatively idle, and even receive no requests, while the weight of the server will be very busy, so this algorithm is sed improvement, that is to say, no matter how much your weight will be assigned to the request. Simply put, there is no need to queue, if there is a real server connection number of 0 will be directly assigned to the past, do not need to be in the sed operation.
(5).LBLC(Locality-Based Least Connections) :Locality-Based Least Connections
Description: The Locality-Based Least Connections algorithm is a load-balanced scheduling for the destination IP address of the request message, and it is mainly used in Cache cluster systems because the destination IP address of the customer request message is changing in Cache clusters. Because the target IP address of a client request message in a Cache cluster is variable, it is assumed that any back-end server can handle any request. The design goal of the algorithm is to improve the access locality of the servers and the main memory Cache hit rate to adjust the processing capacity of the whole cluster system by scheduling the requests with the same target IP address to the same server when the load of the servers is basically balanced.
(6).LBLCR (Locality-Based Least Connections with Replication) :Locality-Based Least Connections with Replication
Description: Locality-Based Least Connections with Replication scheduling algorithm is also a load balancing algorithm for target IP addresses. According to the target IP address of the request, find out the server group corresponding to the target IP address, select a server from the server group according to the principle of "minimum connection", and if the server is not overloaded, send the request to that server; if the server is overloaded, select a server from the cluster according to the principle of "minimum connection". If the server is overloaded, a server is selected from the cluster according to the "minimum connection" principle, and the request is sent to that server by adding the server to the server group. At the same time, when the server group has not been modified for a period of time, the busiest server is removed from the server group to reduce the level of replication.