Several common schemes of load balancing algorithm

Source: Internet
Author: User
Tags database load balancing message queue

General scenarios and application scenarios of load balancing in summary

Polling scheduling

To request scheduling different servers in order of polling; When implemented, the server is generally weighted; this has two benefits:

    1. Performance differences for servers can be assigned different loads;
    2. When a node needs to be removed, it is only necessary to set its weight to 0;

Advantages: Simple and efficient, easy to expand horizontally;

Disadvantage: The uncertainty of the request to the destination node, resulting in its inability to apply to a written scenario (cache, database write)

Scenario: A read-only scenario in a database or application service layer;

Random mode

Requests are randomly distributed to each node, and a balanced distribution can be achieved when the data is large enough;

Advantages: Simple and easy to expand horizontally;

Cons: With round Robin, cannot be used for written scenes;

Application scenario: Database load Balancing, is also only read the scene;

Hash:

According to key to calculate the need to fall on the node, you can guarantee that the same key must fall on the same server;

Advantages: The same key must fall on the same node, so that it can be used to write a read cache scene;

Disadvantage: After a node failure, the hash key will be re-distributed, resulting in a significant decrease in hit ratio;

Resolution: A consistent hash or use keepalived to ensure high availability of any one node, and other nodes on top of the fault;

Application scenario: Cache, have read and write;

Consistent hash:

In the case of a server node failure, only the key affected by this node, the maximum degree of guaranteed hit ratio;

such as the Ketama scheme in Twemproxy;

The production implementation can also be programmed to specify sub-key hashes, thus ensuring that local similarity characteristics of the key can be distributed on the same server;

Advantages: The decrease of hit ratio after node failure is limited;

Application scenario: caching;

Load according to the range of the keys:

According to the range of the key to load, the first 100 million keys are stored to the initial server, one or two billion in the second node;

Advantages: Horizontal expansion is easy, storage is not enough time, add the server to store subsequent new data;

Disadvantage: Uneven load, uneven distribution of database, (data with hot and cold distinction, generally recently registered users more active, so that the subsequent server is very busy, and early nodes idle a lot)

Application Scenario: Database fragmentation load balancing;

The load is modeled on the server node according to the key:

The load is modeled on the server node according to the key, for example, there are 4 servers, key modulo 0 falls on the first node, 1 falls on the second node.

Advantages: Data heat distribution equilibrium, database node load balanced distribution;

Disadvantage: Horizontal expansion is more difficult;

Application Scenario: Database fragmentation load balancing;

Pure dynamic Node Load balancing:

According to CPU, IO, network processing ability to decide how to dispatch the next request;

Advantages: Make full use of the resources of the server to ensure the balance of load processing on the nodes.

Disadvantages: The implementation of complex, real use less;

Without active load balancing:

Use Message Queuing to move to an asynchronous model to eliminate load balancing problems

Load balancing is a push model that always sends data to you, so that all user requests are sent to the message queue, all downstream nodes who are idle, who comes up to fetch data processing, and the message loads after the pull model;

Advantage: Through the buffer of message queue, protect back-end system, the request will not burst the back-end server;

Horizontal expansion is easy, after adding a new node, directly take the queue can be;

Disadvantage: not real-time;

Application scenario: A scene that does not need to be returned in real time;

For example, 12036 after the order, immediately return to the message: your order in line ... After processing completed, and then asynchronous notification;

Several common schemes of load balancing algorithm

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.