Basic (common) Load Balancing Algorithms

Source: Internet
Author: User

This blog reposted from: http://blog.csdn.net/u014649204/article/details/25115039

The design of the balancing algorithm directly determines the performance of the cluster in load balancing. Poor design of the algorithm will lead to load imbalance in the cluster. The main task of the general balancing algorithm is to determine how to select the next cluster node and then forward new service requests to it. Some simple balancing methods can be used independently, and some must be used together with other simple or advanced methods. A good Server Load balancer algorithm is not omnipotent. It is generally used only in some special application environments. Therefore, when investigating the load balancing algorithm, you should also pay attention to the applicability of the algorithm itself, and take a comprehensive consideration based on the characteristics of the cluster during cluster deployment, it combines different algorithms and technologies.

3.1 rotation method:

Rotation algorithms are the simplest and easiest way to implement all scheduling algorithms. In a task queue, each member (node) in the queue has the same status. The rotation method simply rotates and selects members in the group. In the load balancing environment, the balancer sends new requests to the next node in the node queue in turn. In this continuous and cyclical manner, each cluster node is selected in turn under the same status. This algorithm is widely used in DNS domain name round robin.

The rotation method is predictable, and the opportunity for each node to be selected is 1/N. Therefore, it is easy to calculate the node load distribution. The rotation method is typically applicable when the processing capability and performance of all nodes in the cluster are the same. In practical applications, it is generally effective when combined with other simple methods.

3.2 hash

HASH is also called HASH. network requests are sent to cluster nodes according to certain rules through a single-shot irreversible HASH function. The hash method is very powerful when several other balancing algorithms are not very effective. For example, in the case of UDP sessions mentioned above, due to the rotation method and other types of connection information-based algorithms, the starting and ending tags of sessions cannot be identified, which may cause application confusion.

The hash ing based on the data packet source address can solve this problem to some extent: send data packets with the same source address to the same server node, this allows transactions based on high-level sessions to run in an appropriate manner. The hash Scheduling Algorithm Based on the target address can be used in the Web Cache cluster. All access requests directed to the same target site are sent to the same Cache service node by the Load balancer, to avoid the Cache update problem caused by missing pages.

3.3 least connection method

In the least connection method, the balancer records all currently active connections and sends the next new request to the node with the minimum number of connections. This algorithm is applicable to TCP connections. However, because the consumption of system resources varies greatly by different applications, the number of connections cannot reflect the actual application load, therefore, when a heavy Web server is used as a cluster node service (such as an Apache server), the algorithm will have a discount on the load balancing effect. To reduce this adverse effect, you can set the maximum number of connections for each node (expressed by Threshold setting ).

3.4 least missing

In the least missing method, the balancer records requests from each node for a long time and sends the next request to the node with the least request in history. Unlike the least connection method, the least missing record records the number of past connections instead of the current number of connections.

3.5 fastest response method

The balancer records the network response time from itself to each cluster node, and assigns the next connection request to the node with the shortest response time, this method requires the use of ICMP packets or UDP packet-based dedicated technology to actively detect each node.

In most LAN-based clusters, the fastest response algorithm does not work well, because ICMP packets in the LAN basically respond within 10 ms, which does not reflect the differences between nodes; if a balance is made on the WAN, the response time is of practical significance for the user to select the server nearby. In addition, the more scattered the cluster topology, the more effective the method can be. This method is the main method used for advanced Balancing Based on topology redirection.

3.6 encryption Law

Weighted methods can only be used with other methods, which is a good supplement to them. The weighting algorithm consists of multiple priority queues for Load Balancing Based on the node priority or the current Load Status (that is, the weight value). Each connection waiting for processing in the queue has the same processing level, in this way, the same queue can be balanced by the previous rotation or least connection method, while queues are balanced by the order of priority. Here, the weight is an estimate based on the capabilities of each node.


Detailed description on the Internet


Load Balancing Algorithms

We know that the role of a server Load balancer in a server Load balancer device is crucial and plays a crucial role. On the one hand, it receives users' network requests and on the other hand transfers requests to specific application servers according to certain algorithms to achieve load balancing. Therefore, algorithms in Server Load balancer are crucial. Most Server Load balancer devices implement the following algorithms.

   1. Round Robin Scheduling

The Round Robin Scheduling algorithm is used to schedule requests to different servers in turn in the Round Robin mode, that is, each Scheduling runs I = (I + 1) mod n, and select the I server. The advantage of the algorithm is its conciseness. It does not need to record the status of all current connections, so it is a stateless scheduling.

In the actual implementation process, a weight value is usually set for each server, which is the weight round robin scheduling algorithm.

2. Least-Connection Scheduling)

The Least-Connection Scheduling algorithm is used to allocate new Connection requests to servers with the smallest number of connections. The minimum connection scheduling is a dynamic scheduling algorithm that estimates the server load by the number of active connections on the server.

In actual implementation, a weight value is usually set for each server, which is Weighted Least-Connection Scheduling)

   3. Local-based least Link (LBLC)

The Locality-Based Least Connections Scheduling (LBLC) algorithm is a server Load balancer Scheduling Algorithm for the target IP addresses of request packets. Currently, it is mainly used in Cache Cluster Systems, in the Cache cluster, the target IP address of the customer request message changes.

The LBLC scheduling algorithm first finds the Server recently used by the target IP address of the request. If the server is available and is not overloaded, the request is sent to the server. If the server does not exist, if the server is overloaded or has half of the server's workload, use the "least link" principle to select an available server and send the request to the server.

4. Local least Link (LBLCR) with replication)

The Locality-Based Least Connections with Replication Scheduling (LBLCR) algorithm is also used for load balancing of the target IP address. It is mainly used in the Cache cluster system. It differs from the LBLC Algorithm in that it maintains a ing from a target IP address to a group of servers, while the LBLC algorithm maintains a ing from a target IP address to a server.

The LBLCR scheduling algorithm maps "popular" sites to a group of Cache servers (server sets). When the request load of the "popular" site increases, the Cache server in the set is added, to process the increasing load. When the request load of the popular site is reduced, the number of Cache servers in the set is reduced. In this way, the images of the "popular" site are unlikely to appear on all the Cache servers, so as to provide the efficiency of using the Cache cluster system.

   5. Destination Hashing Scheduling)

The Destination Hashing Scheduling algorithm is a load balancing algorithm for the target IP address. However, it is a static ing algorithm that uses a Hash) the function maps a target IP address to a server.

The target address Hash scheduling algorithm first uses the target IP address of the request as the Hash Key to find the corresponding server from the static allocation Hash list, if the server is available and is not overloaded, send the request to the server. Otherwise, null is returned.

   6. Source Hashing Scheduling)

Similar to target address hash scheduling, the only difference is that the hash key of the hash function is based on the source address.

In practical applications, source address hash scheduling and target address hash scheduling can be used in a firewall cluster to ensure the unique entrance and exit of the entire system.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.