Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Consistent Hashing

Avatar for tildascode tildascode
December 08, 2019

Consistent Hashing

What is Consistent Hashing? What’s the motivation behind it, and how distributed caches and storages are taking advantage of it?
We’ll first review the general concept of hashing and its purpose, followed by a description of distributed hashing and the problems it entails. In turn, that will lead us to us to our title subject and its benefits.

Avatar for tildascode

tildascode

December 08, 2019

More Decks by tildascode

Other Decks in Technology

Transcript

  1. Introduction ü Teodora Petkova ü Lidl Digital CoE Bulgaria ü

    Team Battery ü Java Developer 3>4 years ü @teodorrrra 7+ followers Hey everybody!
  2. Agenda Ø The Motivation Behind Ø Real-World Applications Ø Distributed

    Hashing Ø A Simple Approach Ø A Not So Simple Approach using Consistent Hashing
  3. Distributed Hashing Hash Function We could first apply a hash

    function to ProductIDs and URLs. What this would give us is: 1) a more unified problem 2) working with fixed-size values hashFunction(1234)=0 hashFunction(2345)=1 … hashFunction(XXXX)=7
  4. A Simple Approach To Distributed Hashing Hashes ∈ {0...7} N

    = 4 (servers) ServerIndex ∈ {0...3} ServerIndex = Hash % N
  5. A Simple Approach To Distributed Hashing The Rehashing Problem: Adding

    a server Hashes ∈ {0...7} N = 5 (servers) ServerIndex ∈ {0...4} ServerIndex = Hash % N
  6. A Simple Approach To Distributed Hashing The Rehashing Problem: Removing

    a server Hashes ∈ {0...7} N = 3 (servers) ServerIndex ∈ {0...2} ServerIndex = Hash % N
  7. A Simple Approach To Distributed Hashing Results ü A server

    can be dynamically added or removed qMinimal amount of data is moved between the servers when we add/remove a server
  8. Consistent Hashing Results Consistent Hashing helps distributed caches and storages

    with the following things: ü A server can be dynamically added or removed ü Minimal amount of data is moved between the servers when we add/remove a server