Basic (common) algorithm for load Balancing

Source: Internet
Author: User

The design of the balance algorithm directly determines the performance of the cluster in load balancing, the design of the poor algorithm, will lead to the load imbalance of the cluster. The main task of the general balancing algorithm is to decide how to select the next cluster node and then forward the new service request to it. Some simple balancing methods can be used independently, and some must be combined with other simple or advanced methods. And a good load-balancing algorithm is not omnipotent, it is generally only in some special application environment in order to maximize the effectiveness. Therefore, in the study of load balancing algorithm, we should pay attention to the application of the algorithm itself, and in the cluster deployment time according to the characteristics of the cluster's own comprehensive consideration, the different algorithms and technologies combined to use.

3. 1 Rotation method:

The rotation algorithm is the simplest and easiest way to implement all scheduling algorithms. In a task queue, each member (node) of the queue has the same status, and the rotation method simply rounds the selection in this group of members. In a load-balanced environment, the equalizer rotates the new request to the next node in the node queue, so that the nodes of each cluster are rotated to be selected in equal position. This algorithm is widely used in DNS domain name polling.

The rotation activity is predictable, and the chance of each node being chosen is 1/n, so it is easy to calculate the load distribution of the nodes. The rotation method is typical for all nodes in the cluster with the same processing capability and performance, in practical applications, it is generally more effective when used in conjunction with other simple methods.

3. 2 Hash method

Hash method is also called hashing (hash), through the single-shot non-reversible hash function, according to some rules to send network requests to the cluster node. Hashing show special power when several other types of equilibrium algorithms are not very effective. For example, in the case of UDP sessions mentioned earlier, because of the rotation method and several other types of algorithms based on connection information, it is not possible to recognize the beginning and end of a session, which can cause confusion in application.

A hash map based on the source address of the packet can solve this problem to some extent: sending packets with the same source address to the same server node, which allows the transactions based on the high-level session to run in the proper way. In contrast, the hash scheduling algorithm based on the destination address can be used in the Web cache cluster, and access requests to the same target site are sent to the same cache service node by the load balancer to avoid the update cache problem caused by the missing page.

3. 3 Minimum Connection method

In the least-connection method, the Balancer records the current active connection and sends the next new request to the node that currently contains the fewest number of connections. This algorithm is for TCP connections, but because the consumption of system resources by different applications can vary greatly, and the number of connections does not reflect the actual application load, so when using a heavy Web server as a cluster node service (such as the Apache server), the algorithm has a discount on the effect of balancing the load. To reduce this negative impact, you can set the maximum number of connections per node (which is reflected by the threshold setting).

3. 4 Minimum Missing method

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

3. 5 Fastest Response method

The Balancer records the network response time of itself to each cluster node and assigns the next incoming connection request to the node with the shortest response time, which requires the use of ICMP packets or UDP packet-based specialized techniques to proactively probe each node.

In most LAN-based clusters, the quickest response algorithm is not very good, because the ICMP packets in the LAN are basically in the 10ms to complete the response, not the difference between the nodes, if the balance on the WAN, the response time for the user to choose the nearest server is of practical significance , and the more dispersed the cluster topology, the more effective the method can be. This approach is the primary approach to advanced balancing based on topology redirection.

3. 6 Weighting method

Weighted methods can only be used in combination with other methods, which is a good complement to them. The weighted algorithm forms a multi-priority queue of load balancing based on the priority of the node or the current load state (that is, weights), and each pending connection in the queue has the same processing level, so that the same queue can be balanced by the previous rotation method or the least connection method, The queues are balanced in priority order. Here the weights are an estimate based on the capabilities of each node.


Basic (common) algorithm for load Balancing

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.