当前位置:网站首页>There are some limitations in cluster expansion and contraction
There are some limitations in cluster expansion and contraction
2022-06-23 08:13:00 【User 7737280】
such as : A server node is down , The calculation formula starts from hash(key)% 3 Turned into hash(key)% 2, The results will change , At this point, you want to access a key, This key Open selection The approximate cache location rate will change , So before caching key The data will also lose its function and significance .
A large number of caches fail at the same time , Avalanche causing cache , This leads to the unavailability of the whole cache system , This is basically unacceptable , In order to solve and optimize the above situation , Uniformity hash The algorithm came into being ~ that , How does the consistent hash algorithm solve the above problems ?
The server maps to hash Ring At this time, the calculation formula starts from hash(key)% N Turned into **hash( The server ip)% 232**, Use the server IP address hash Calculation , Use the hash result to 232 modulus , The result must be a 0 To 2^32-1 Integer between , And this integer is mapped to hash The position on the ring represents a server , In turn node0、node1、node2 Open selection Three cache servers are mapped to hash On the ring . How does it optimize the addition and reduction of nodes in the cluster ,http://www.gongxuanwang.com Cache service caused by common modulo algorithm , The problem of large area unavailability ?
Let's take a look at the scenario of capacity expansion , If business volume surges , The system needs to be expanded to add a server node-4, just node-4 Mapped to node-1 and node-2 Between , Object mapping nodes in a clockwise direction , Found originally cached in node-2 On the object key-4、key-5 Is remapped to node-4 On , Open selection However, during the whole expansion process, only node-4 and node-1 A small amount of data between nodes . Uniformity Hash The algorithm introduces a Virtual node Mechanism , That is, calculate multiple for each server node hash value , They all map to hash On the ring , Objects mapped to these virtual nodes key, It will eventually be cached on the real node .
Virtual node hash The calculation can usually adopt , Of the corresponding node IP Address plus number suffix hash(10.24.23.227#1) The way , for instance ,node-1 node IP by 10.24.23.227, Normal calculation node-1http://www.gongxuanwang.com Of hash value .
hash(10.24.23.227#1)% 2^32Suppose we give node-1 Set up three virtual nodes ,node-1#1、node-1#2、node-1#3, Carry them on hash Take the mold after .
边栏推荐
- flutter 制作TabBar的圆角
- Configuration asmx not accessible
- Deep learning ----- different methods to realize vgg16
- Do not put files with garbled names into the CFS of NFS protocol
- transform的结构及用法
- imperva-查找正则匹配超时的方法
- Vulnhub | DC: 4 |【實戰】
- Active Directory之AD对象
- 记一次高校学生账户的“从无到有”
- [kubernetes] download address of the latest version of each major version of kubernetes
猜你喜欢
随机推荐
Decomposition - command injection
GTEST死亡测试
QT project error: -1: error: cannot run compiler 'clang++' Output:mingw32-make. exe
A record of "from scratch" in college student accounts
Moodle e-learning platform fixes the session hijacking error that leads to pre authorized rce
转盘式视觉筛选机及其图像识别系统
9 ways in which network security may change in 2022
观察者模式
Markdown learning
Apache Solr 任意文件读取复现
Google common syntax
Acwing game 56 [End]
Socket programming -- select model
Socket programming (multi process)
The essence of five good books on wealth and freedom
Interview questions of a company in a certain month of a certain year (1)
爬虫框架
[kubernetes] download address of the latest version of each major version of kubernetes
Quickly create a consumer cluster
Production environment server environment setup + project release process





![[try to hack] IP address](/img/ab/ed91f3094ac913a0d79448a2d19015.png)



