Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.

The easiest consistent hashing

The easiest Consistent Hashing

  • Inicia sesión para ver los comentarios

The easiest consistent hashing

  1. 1. The Easiest Consistent Hashing charsyam@naver.com
  2. 2. Consistent Hashing?
  3. 3. WHY?
  4. 4. There was data In the beginning.
  5. 5. 1 2 3 4 5 6 7 89
  6. 6. How do you distribute data pairly into 3 servers? Considering the future.
  7. 7. 1 2 3 4 5 6 7 8 9 Sequence
  8. 8. 1 2 3 4 5 6 7 8 9 Modular
  9. 9. If you add one server, or remove one server What happened?
  10. 10. 1 2 3 4 5 6 Add one server for Sequence 7 8 9
  11. 11. Add one server for Modular 1 2 3 4 5 6 7 8 9
  12. 12. How do you redistribute these data?
  13. 13. Redistribute by Modular 1 2 3 4 5 6 7 8 9
  14. 14. Most of data is redistributed!
  15. 15. Redistribution is Burden.
  16. 16. What is a good way to reduce redistribution?
  17. 17. Consistent Hashing Can Do!!!
  18. 18. Consistent Hashing redistribute only N/K data N = data size K = servers
  19. 19. Key Concept is Hash
  20. 20. What is main concept of hash
  21. 21. If you use same hash function? The result is always the same.
  22. 22. hash(“abc”) = 1 hash(“abc1”) = 2 hash(“abc”) = 1
  23. 23. You have 3 servers. 10.0.1.1 10.0.1.2 10.0.1.3
  24. 24. There is a hash function. y = hash(x)
  25. 25. You hash 3 servers hash(“10.0.1.1”) = 100 hash(“10.0.1.2”) = 400 hash(“10.0.1.3”) = 700 Just Giving server address as key
  26. 26. Just define a rule. We will store a key in hash(key) is higher and the nearest one.
  27. 27. hash(key) Hash value hash(“10.0.1.1”) 100 hash(“10.0.1.2”) 400 hash(“10.0.1.3”) 700
  28. 28. There is key “redis” hash(“redis”) = 200 Where we store it?
  29. 29. hash(key) Hash value hash(“10.0.1.1”) 100 hash(“redis”) 200 in hash(“10.0.1.2”) hash(“10.0.1.2”) 400 hash(“10.0.1.3”) 700
  30. 30. There is key “charsyam” hash(“charsyam”) = 450 Where we store it?
  31. 31. hash(key) Hash value hash(“10.0.1.1”) 100 hash(“redis”) 200 in hash(“10.0.1.2”) hash(“10.0.1.2”) 400 hash(“charsyam”) 450 in hash(“10.0.1.3”) hash(“10.0.1.3”) 700
  32. 32. There is key “udemy” hash(“udemy”) = 50 Where we store it?
  33. 33. hash(key) Hash value hash(“udemy”) 50 in hash(“10.0.1.1”) hash(“10.0.1.1”) 100 hash(“redis”) 200 in hash(“10.0.1.2”) hash(“10.0.1.2”) 400 hash(“charsyam”) 450 in hash(“10.0.1.3”) hash(“10.0.1.3”) 700
  34. 34. There is key “web” hash(“web”) = 1000 Where we store it?
  35. 35. There is no server has higher hash value 1000. Where we can store it?
  36. 36. Think it is Circle
  37. 37. hash(key) Hash value hash(“udemy”) 50 in hash(“10.0.1.1”) hash(“10.0.1.1”) 100 hash(“redis”) 200 in hash(“10.0.1.2”) hash(“10.0.1.2”) 400 hash(“charsyam”) 450 in hash(“10.0.1.3”) hash(“10.0.1.3”) 700 hash(“web”) 1000 in hash(“10.0.1.1”)
  38. 38. Key “web” is stored in First Server.
  39. 39. If we add new server It is “10.0.1.4”. And hash(“10.0.1.4”) = 500
  40. 40. hash(key) Hash value hash(“udemy”) 50 in hash(“10.0.1.1”) hash(“10.0.1.1”) 100 hash(“redis”) 200 in hash(“10.0.1.2”) hash(“10.0.1.2”) 400 DELETED hash(“charsyam”) 450 hash(“10.0.1.4”) 500 hash(“10.0.1.3”) 700 hash(“web”) 1000 in hash(“10.0.1.1”)
  41. 41. After adding “10.0.1.4” Key “charsyam” is missing
  42. 42. But other keys are never changed.
  43. 43. You can still find key “udemy” in “10.0.1.1”
  44. 44. There is key “charsyam” hash(“charsyam”) = 450 Where we store it?
  45. 45. hash(key) Hash value hash(“udemy”) 50 in hash(“10.0.1.1”) hash(“10.0.1.1”) 100 hash(“redis”) 200 in hash(“10.0.1.2”) hash(“10.0.1.2”) 400 hash(“charsyam”) 450 in hash(“10.0.1.4”) hash(“10.0.1.4”) 500 hash(“10.0.1.3”) 700 hash(“web”) 1000 in hash(“10.0.1.1”)
  46. 46. A Add A Server
  47. 47. A B Add B Server
  48. 48. A BC Add C Server
  49. 49. A BC Add Key 1 1
  50. 50. A BC Add Key 2 1 2
  51. 51. A BC Add Key 3 1 2 3
  52. 52. A BC Add Key 4 1 2 3 4
  53. 53. A BC Add Key 5 1 2 3 4 5
  54. 54. A C Fail B Server 2 3 4 5
  55. 55. A C Add Key 1 2 3 4 5 1
  56. 56. In Next Lecture ● We will discuss belows topics ○ How to use Consistent Hashing in Real World.

×