当前位置:网站首页>[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 .
边栏推荐
- [set theory] order relation (hastu example | divisive relation hastu | inclusive relation hastu | refinement relation hastu)
- Golang 中string和int类型相互转换
- Minimap plug-in
- Detailed explanation of all transfer function (activation function) formulas of MATLAB neural network
- UE4 source code reading_ Bone model and animation system_ Animation process
- Get to know unity2 for the first time
- Swagger document configuration
- Markdown directory generation
- 【Rust 笔记】12-闭包
- matlab神經網絡所有傳遞函數(激活函數)公式詳解
猜你喜欢

Collection interface

图像处理8-CNN图像分类

Detailed explanation of all transfer function (activation function) formulas of MATLAB neural network

了解小程序的笔记 2022/7/3

Student educational administration management system of C # curriculum design

Advanced OSG collision detection

UE4 source code reading_ Mobile synchronization

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

Explain sizeof, strlen, pointer, array and other combination questions in detail

Notes on understanding applets 2022/7/3
随机推荐
Dealing with duplicate data in Excel with xlwings
UE4 source code reading_ Bone model and animation system_ Animation node
Unity change default editor
Unity interactive water ripple post-treatment
Constraintlayout's constraintset dynamically modifies constraints
Image processing 8-cnn image classification
Delete the last character of the string in golang
Golang url的编码和解码
Classes and objects
Basic operation and process control
Creation of osgearth earth files to the earth ------ osgearth rendering engine series (1)
Gradle's method of dynamically modifying APK package name
Why can void * be a general pointer
Golang 时间格式整理
了解小程序的笔记 2022/7/3
What is BFC?
【Rust 笔记】11-实用特型
[K & R] Chinese Second Edition personal questions Chapter1
C#课程设计之员工信息管理系统
UE4 source code reading_ Bone model and animation system_ Animation process