Understanding of the consistent hashing algorithm

Source: Internet
Author: User
Tags rehash

On the consistent hashing algorithm, there are many blog posts on the Web are explained. 2 recommended.

Http://blog.codinglabs.org/articles/consistent-hashing.html

http://blog.csdn.net/cywosp/article/details/23397179

To summarize:

1. Online blog Examples of the result of the hash value is defined in 0-232-1, is actually not necessary, you can set a smaller than this range, or larger than this range, is possible, it is important that it is a ring.

2. Consistent hashing does not guarantee that the node is mapped to the equilibrium, assuming that the hash value is balanced, then the node to be balanced mapping, you must make the distance between the nodes equal, that is, the circumference of each node split the ring.

3. When a failed node is present, a consistent hash does not guarantee that the value on the failed node can be recovered by the algorithm (unless the primary and standby mechanism is implemented)

4. When the fault node is removed, the pressure on the next node of the fault node increases (if the pressure on each node is balanced, the pressure increases by 1 time times).

5. When inserting a new node, the consistent hashing algorithm does not avoid rehash steps, but it minimizes the range of rehash, simply returning part of the data from the previous node of the new node to the new node.

6, when the value of the hashing algorithm is unbalanced, the pressure of each node on the ring is unbalanced. You can use the method of adding virtual nodes to make the balance. You can insert multiple virtual nodes after the Hotspot node, and once the mapping falls on the virtual node, the other hash algorithms are mapped to the lower-pressure nodes. The algorithm used can be simple and rude, for example, a chestnut:

For example, in the absence of a virtual node, assuming that the hash algorithm due to the imbalance, falling on the node 4 and 5 of the hash value is particularly large, it is bound to cause the node 5 pressure is larger, and at this time if the node 6 and Node 2 pressure is relatively small, Then 2 virtual nodes (Node A and Node B) are inserted between node 4 and node 5, according to the algorithm of consistent hashing, the hash value between Node A and node 5 falls to node 5, and the hash value of Node A and Node B falls on Node A, and the hash between node B and node 4 falls on Node B. However, Node A and Node B are virtual nodes, so you can force node A to map to node 6, and Node B is forced to map to Node 2, so that the pressure on node 5 is mitigated, which makes all nodes load relatively balanced.

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" clipboard "border=" 0 "alt=" clipboard "src=" http://s3.51cto.com/wyfs02/M01/5A/37/ Wkiom1t5uvbzhdoqaac4fdw-pba215.jpg "" 426 "height=" 402 "/>

The above is some summary, if not, welcome to point out the correction.

Understanding of the consistent hashing 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.