NW-study / system-design-interview

8 stars 0 forks source link

[Chapter 05] Q&A #5

Open zziri opened 2 years ago

zziri commented 2 years ago

[Chapter 05] 안정 해시 설계

zziri commented 2 years ago

지훈

travelbeeee commented 2 years ago

현석

easyfordev commented 2 years ago

이지

meloncha commented 2 years ago

민석

안정 해시가 최고의 해답일까?

https://dgryski.medium.com/consistent-hashing-algorithmic-tradeoffs-ef6b8e2fcae8

https://itnext.io/introducing-consistent-hashing-9a289769052e

Rendezvous Hashing

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
}

Jump Consistent Hashing

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;
}

image

장점

KKambi commented 2 years ago

한비

How discord scaled elixir to 5000000 concurrent users

https://discord.com/blog/how-discord-scaled-elixir-to-5-000-000-concurrent-users

elixir : erlang vm이라는 가상머신 위에서 작동하는 언어. 함수형 / 분산처리 / 동시성 / 실시간 등의 특징.


디스코드 pub/sub 기능


Message Fanout


결론

kihyun-yang commented 2 years ago

기현