Open zziri opened 2 years ago
질문 : 가상 노드를 늘리면 (무조건) 좋은가?에 대해 그렇지 않다. 가상 노드 데이터를 저장할 공간은 더 많이 필요하게 될 것이다. tradeoff가 있다. 라고 했는데... 무슨 말인지 살짝 헷갈려서... 설명해주실 분 있으신가요?
공유 : 안정 해시 기술 적용 사례로 AWS의 DynamoDB
의 파티셔닝 관련 컴포넌트, Apache Cassandra
클러스터에서의 데이터 파티셔닝이 언급되었는데, 둘 다 NoSQL 분산(Distributed) 데이터 베이스이다.
https://dgryski.medium.com/consistent-hashing-algorithmic-tradeoffs-ef6b8e2fcae8
Jump Hash
Multi-Probe Consistent Hashing
Rendezvous Hashing
Maglev Hashing
알고리즘 별로 걸리는 시간
CHash(Consistent Hashing) 의 경우 시간 복잡도 O(logN) 이다
https://itnext.io/introducing-consistent-hashing-9a289769052e
type RendezVous struct {
nodes []Node
}
type Node struct {
id string
}
func (r *RendezVous) Get(key string) (*Node, error) {
length := uint32(len(r.nodes))
var maxHashValue = hash(key, r.nodes[0].id, length)
result := 0
for index, node := range r.nodes[1:] {
currentHashValue := hash(key, node.id, length)
if currentHashValue > maxHashValue {
maxHashValue = currentHashValue
result = index
}
}
return &r.nodes[result], nil
}
int32_t JumpConsistentHash(uint64_t key, int32_t num_buckets) {
int64_t b = 1, j = 0;
while (j < num_buckets) {
b=j;
key = key * 2862933555777941757ULL + 1; // Did you say magic number?
j = (b + 1) * (double(1LL << 31) / double((key >> 33) + 1));
}
return b;
}
장점
https://discord.com/blog/how-discord-scaled-elixir-to-5-000-000-concurrent-users
elixir : erlang vm이라는 가상머신 위에서 작동하는 언어. 함수형 / 분산처리 / 동시성 / 실시간 등의 특징.
디스코드 pub/sub 기능
Message Fanout
결론
[Chapter 05] 안정 해시 설계