当前位置:网站首页>[concurrent programming] consistency hash
[concurrent programming] consistency hash
2022-07-03 08:32:00 【keeper42】
Considering that every node of the distributed system may fail , And new nodes are likely to be added dynamically , How to ensure that the system can still provide good services when the number of nodes changes , It's worth considering , Especially when designing distributed cache system , If a server fails , For the whole system, if we do not use the appropriate algorithm to ensure the consistency , Then all data cached in the system may fail ( That is, because the number of system nodes becomes smaller , The client needs to recalculate an object when requesting it hash value ( Usually related to the number of nodes in the system ), because hash The value has changed , So it's very likely that the server node where the object is stored... Can't be found ), So consistency hash It's very important , Well distributed cahce Consistency in the system hash The algorithm should satisfy the following aspects :

- Balance (Balance)
Balance means that hash results can be distributed to all buffers as much as possible , This allows all buffer space to be used . Many hash algorithms can satisfy this condition .
- monotonicity (Monotonicity)
Monotonicity means that if something has already been hashed into the corresponding buffer , There are new buffers added to the system , Then the hash result should be able to ensure that the original allocated content can be mapped to the new buffer , Instead of being mapped to other buffers in the old buffer collection . Simple hash algorithm often can not meet the monotonicity requirements , Like the simplest linear hash :x = (ax + b) mod (P), In the upper form ,P Indicates the size of all buffers . It's not hard to see. , When the buffer size changes ( from P1 To P2), All the original hash results will change , Thus, it does not meet the requirement of monotonicity . The change in hash results means that when the buffer space changes , All mapping relationships need to be updated in the system . And in the P2P In the system , Changes in buffering are equivalent to Peer Join or exit the system , The situation is P2P It happens frequently in the system , Therefore, it will bring great calculation and transmission load . Monotonicity is that hash algorithm can deal with this situation .
- Dispersion (Spread)
In a distributed environment , The terminal may not see all the buffers , But only part of it . When the terminal wants to map the content to the buffer through the hash process , Because different terminals may see different buffer ranges , This leads to inconsistent hash results , The end result is that the same content is mapped to different buffers by different terminals . This situation should be avoided , Because it causes the same content to be stored in different buffers , Reduce the efficiency of system storage . Dispersion is defined as the severity of the above . A good hash algorithm should be able to avoid inconsistencies as much as possible , That is to minimize the dispersion .
- load (Load)
The load problem is actually looking at decentralization from another perspective . Since different terminals may map the same content to different buffers , So for a particular buffer , It can also be mapped to different content by different users . It's the same as dispersion , This situation should also be avoided , So a good hash algorithm should be able to reduce the load of buffer as much as possible .
- Smoothness (Smoothness)
Smoothness refers to the consistency between the number of cache servers and the number of cache objects .
边栏推荐
- Cloudcompare learning (1) - cloudcompare compilation and common plug-in implementation
- 单调栈-503. 下一个更大元素 II
- Dotween plug-in
- 了解小程序的笔记 2022/7/3
- About the problem that the editor and the white screen of the login interface cannot be found after the location of unityhub is changed
- [cloud native] introduction and use of feign of microservices
- Basic operation and process control
- One dimensional array two dimensional array (sort Max insert sort)
- UE4 plug in development
- VIM learning notes from introduction to silk skating
猜你喜欢

Three characteristics

How to establish rectangular coordinate system in space

Base64和Base64URL

Visual Studio (VS) shortcut keys

Simply start with the essence and principle of SOM neural network

Constraintlayout's constraintset dynamically modifies constraints

100 GIS practical application cases (78) - Multi compliance database design and data warehousing

【云原生】微服务之Feign的介绍与使用

Vscode, idea, VIM development tool shortcut keys

數據庫應用技術課程設計之商城管理系統
随机推荐
Unity notes 1
swagger文档配置
Chocolate installation
UE4 call DLL
Student educational administration management system of C # curriculum design
Message pack in C deserializes array objects
Why can void * be a general pointer
Basic operation and process control
Golang 时间格式整理
MySQL 8
Huawei interview summary during the epidemic
About the problem that the editor and the white screen of the login interface cannot be found after the location of unityhub is changed
Vscode, idea, VIM development tool shortcut keys
基于SSM的校园失物招领平台,源码,数据库脚本,项目导入运行视频教程,论文撰写教程
redis集群系列四
MXone Pro自适应2.0影视模板西瓜视频主题苹果cmsV10模板
What is BFC?
Pit & ADB wireless debugging of vivo real machine debugging
P1596 [USACO10OCT]Lake Counting S
Un système de gestion de centre commercial pour la conception de cours de technologie d'application de base de données