Consistent Hashing: Concept, Ring, Virtual Nodes, Replication, and Trade-offs

What problem does consistent hashing solve?

Toca para voltear
1 / 5(10 total)

Apuntes

HomeBlogCoursesAboutContact Consistent Hashing 7 min read Authors avatar Name Karan Pratap Singh Twitter @karan_6864 banner Table of Contents Let's first understand the problem we're trying to solve. Why do we need this? In traditional hashing-based distribution methods, we use a hash function to hash our partition keys (i.e. request ID or IP). Then if we use the modulo against the total number of nodes (server or databases). This will give us the node where we want to route our request. simple-hashing Hash(key1)→H1 mod N=Node0Hash(key2)→H2 mod N=Node1Hash(key3)→H3 mod N=Node2...Hash(keyn)→Hn mod N=Noden−1\begin{align*} & Hash(key_1) \to H_1 \bmod N = Node_0 \\ & Hash(key_2) \to H_2 \bmod N = Node_1 \\ & Hash(key_3) \to H_3 \bmod N = Node_2 \\ & ... \\ & Hash(key_n) \to H_n \bmod N = Node_{n-1} \end{align*} ​ Hash(key 1 ​ )→H 1 ​ modN=Node 0 ​ Hash(key 2 ​ )→H 2 ​ modN=Node 1 ​ Hash(key 3 ​ )→H 3 ​ modN=Node 2 ​ ... Hash(key n ​ )→H n ​ modN=Node n−1 ​ ​ Where, key: Request ID or IP. H: Hash function result. N: Total number of nodes. Node: The node where the request will be routed. The problem with this is if we add or remove a node, it will cause N to change, meaning our mapping s...

Estudia con juegos interactivos

Sube tus apuntes y genera flashcards, examenes y mas con IA

Empezar gratis