Consistent Hashing | The Backend Engineering Show

แชร์
ฝัง
  • เผยแพร่เมื่อ 10 มิ.ย. 2024
  • In this episode of the backend engineering show I discuss consistent hashing a very important algorithm in distributed computing specially in database systems such as Apache Cassandra and DynamoDB.
    0:00 Intro
    2:00 Problem of Distributed Systems
    5:00 When to Distribute
    7:00 Simple Hashing
    9:30 Where Simple Hashing Breaks
    11:40 Consistent Hashing
    18:00 Adding a Server
    21:15 Removing a Server
    22:30 Limitations
    Fundamentals of Networking for Effective Backends udemy course (link redirects to udemy with coupon)
    network.husseinnasser.com
    Fundamentals of Database Engineering udemy course (link redirects to udemy with coupon)
    database.husseinnasser.com
    Introduction to NGINX (link redirects to udemy with coupon)
    nginx.husseinnasser.com
    Python on the Backend (link redirects to udemy with coupon)
    python.husseinnasser.com
    Become a Member on TH-cam
    / @hnasr
    Arabic Software Engineering Channel
    / @husseinnasser
    🔥 Members Only Content
    • Members-only videos
    🏭 Backend Engineering Videos in Order
    backend.husseinnasser.com
    💾 Database Engineering Videos
    • Database Engineering
    🎙️Listen to the Backend Engineering Podcast
    husseinnasser.com/podcast
    Gears and tools used on the Channel (affiliates)
    🖼️ Slides and Thumbnail Design
    Canva
    partner.canva.com/c/2766475/6...
    Stay Awesome,
    Hussein
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 67

  • @hnasr
    @hnasr  ปีที่แล้ว +5

    Learn about the fundamentals of Database Engineering Get my course database.husseinnasser.com

  • @bibekjoshi9021
    @bibekjoshi9021 หลายเดือนก่อน +1

    I scoured internet to understand this for last 2 hours. And i stumbled upon hussein's video's again... everything is crystal clear now.
    Excited for your new course on OS , bought it but need to go through it 😁😁😁😁

  • @sharvyahmed
    @sharvyahmed หลายเดือนก่อน

    Hussein, you explain things so nicely! The depth of your knowledge can be easily seen. Keep doing the great work :)

  • @PrashantKhanolkarUSA
    @PrashantKhanolkarUSA ปีที่แล้ว +1

    My mind is blown the way you explained this topic

  • @MallikarjunRaoShankesi
    @MallikarjunRaoShankesi 3 หลายเดือนก่อน

    Excellent explanation! Seen many videos but this one cleared everything....

  • @startup_cult
    @startup_cult ปีที่แล้ว +2

    This explanation is so beautiful man, loved it. Consistent Hashing feels like magic

  • @AleksandarT10
    @AleksandarT10 ปีที่แล้ว +2

    Great topic, its amazing to see great products such as Dynamo and Cassandra use this advanced ideas!
    Would like to see more topics like that

  • @vikramragunathan6392
    @vikramragunathan6392 ปีที่แล้ว +1

    Possibly the best explanation for Consistent Hashing. :)

  • @Altamashattari786
    @Altamashattari786 ปีที่แล้ว +8

    Beautiful explanation of this complicated topic :) Thank you Hussein !

  • @lakhveerchahal
    @lakhveerchahal ปีที่แล้ว +1

    What a great effort to explain all this!!

  • @potaraju92
    @potaraju92 2 หลายเดือนก่อน

    You have incredible talent to teach

  • @channuangadi7504
    @channuangadi7504 7 หลายเดือนก่อน

    What an amazing explanation without any fancy writing and animation

  • @driziiD
    @driziiD ปีที่แล้ว

    i finally get it thanks! everytime i visit your channel i'm rest assured that im going to actually understand what you're teaching :)

  • @vinoths7140
    @vinoths7140 4 หลายเดือนก่อน

    Amazing explanation, Thank You.

  • @kartheek6495
    @kartheek6495 ปีที่แล้ว

    Thank you so much sir for making this concept super simple

  • @fadygamilmahrousmasoud5863
    @fadygamilmahrousmasoud5863 6 หลายเดือนก่อน

    and now this is what we call a state of art

  • @eshaanpandey7353
    @eshaanpandey7353 7 หลายเดือนก่อน

    Nicely explained.

  • @yousefkhaled2
    @yousefkhaled2 ปีที่แล้ว +1

    nice video understood perfectly, thnx

  • @addiegupta
    @addiegupta ปีที่แล้ว

    great video as always. thank you

  • @simplefinance5165
    @simplefinance5165 ปีที่แล้ว +4

    I was avoiding this topic from a very long time due to complexity, you explained it so well. Thanks.

  • @brymstoner
    @brymstoner ปีที่แล้ว +1

    very interesting. thanks hussein! i do something similar for flat file db's. similar that is in ranging. so for every object between numbers n and n, find them in file x.

  • @Adi-xy8iu
    @Adi-xy8iu ปีที่แล้ว

    Great explanation!

  • @samart3010
    @samart3010 11 หลายเดือนก่อน

    What a great talk Hussain. ❤

  • @luisphilipe
    @luisphilipe ปีที่แล้ว

    Awesome content. Keep doing it!

  • @harirambj
    @harirambj ปีที่แล้ว

    Great explanation

  • @officialismailshah
    @officialismailshah 9 หลายเดือนก่อน

    Nicely described your struggle show in this video keep it up bro

  • @alejandrombc
    @alejandrombc ปีที่แล้ว +7

    Awesome video!!. One question with the ring topology, how can we mantain a “right” amount of load through the servers?. In your example if you add servers that go around the same degrees you might have a debalanced system (like 4 servers between 0-90 and just 2 between 180-270).
    Is this a limitation or I dont quite get it right? 🤔

    • @AjaSiva
      @AjaSiva ปีที่แล้ว +2

      in real life there are virtual nodes for each servers like s0_0, s0_1, s0_2..and so on. These are distributed in the ring, so eventually you will have a more balanced distribution

  • @tanumoymajumdar874
    @tanumoymajumdar874 11 หลายเดือนก่อน

    Beautiful.

  • @programmingwithjavascript3579
    @programmingwithjavascript3579 ปีที่แล้ว +5

    After watching gaurav sen video. I would say, hussain nesser is best👍💯 🙏

  • @dhanushshetty7840
    @dhanushshetty7840 ปีที่แล้ว

    What would happen if your server count goes above 360 in the above scenario? Do you have to reshuffle all keys one time using higher number?

  • @himanshusharma9817
    @himanshusharma9817 ปีที่แล้ว +1

    Can you talk about virtual nodes and data replication as the next part of this video ?

  • @HamzaKhan-oz2xm
    @HamzaKhan-oz2xm ปีที่แล้ว +1

    NIcely explained

  • @roshedulalamraju7936
    @roshedulalamraju7936 ปีที่แล้ว

    In consistent hashing , if one datanase is full and goes to read only mode but can't insert new data, how does this works?

  • @mohammedsalman3397
    @mohammedsalman3397 ปีที่แล้ว

    are you reading my mind, I was just writing a hashtable for my opengl renderer to cache unifroms :)

  • @saurabhjagtap
    @saurabhjagtap ปีที่แล้ว

    Well taking this example, you cannot have more than 360 servers, right? What if the number of servers increases to 361, how will we handle such complexities? Even if we change the modulo to, lets say, 720: this will add up more to complexities, like earlier result was 1 (when we did %360) now it will be 361. How would we handle such scenarios?

  • @ravitejavankam2977
    @ravitejavankam2977 ปีที่แล้ว +1

    Some ideas:
    1. While adding server: we can have dedicated slave for each server and we can promote the slave as master like in this case slave of S90 will act as S50.
    2. When removing server: instead of dedicated server we can also have slave on adjacent nodes for eg S90 slave will be in S0 and S180 and if we want to remove S90 then slave data of S90 in S180 will act as leader.

    • @shahman1
      @shahman1 ปีที่แล้ว

      Can you elaborate the slave idea? Would the slave be another server along with S90 called S90slave (for example)? And when a new one is added (S50 in this case), the S90slave becomes S50 but with only the values that belong to S50?

    • @ravitejavankam2977
      @ravitejavankam2977 ปีที่แล้ว +1

      @@shahman1 Yes S90slave will act as leader for S50 and can discard data outside the degree.

  • @khalidgria6863
    @khalidgria6863 ปีที่แล้ว

    very important algorithm in distributed computing specially in database systems such as Apache Cassandra and DynamoDB.

  • @AJ-fb9pk
    @AJ-fb9pk ปีที่แล้ว

    I did not understand why to use consistent hashing, after watching this I now understand why and also only noticed why it is called consistent. The hashing that is consistent even when adding new nodes.

    • @AJ-fb9pk
      @AJ-fb9pk ปีที่แล้ว

      Almost consistent

  • @andresgutierrez1804
    @andresgutierrez1804 ปีที่แล้ว

    Thx for the cupon

  • @jobosan4855
    @jobosan4855 ปีที่แล้ว

    Index 3!

  • @anthonyoleinik6472
    @anthonyoleinik6472 ปีที่แล้ว +1

    When we add another server to the ring, won’t that server and the next server in the ring get half the load? I.e the loads are now unbalanced.
    Is there a solution for this or is this a given caveat?

    • @anthonyoleinik6472
      @anthonyoleinik6472 ปีที่แล้ว

      Interesting trade off… adding a server moves less data, but you end up with an unbalanced load

    • @anthonyoleinik6472
      @anthonyoleinik6472 ปีที่แล้ว

      But I guess in the first place, if your load is initially balanced and you start running out of space, you run out of space on all the servers, not just one. So you would add N servers and your load is balanced again.
      3 comments instead of just editing the first for that sweet sweet youtube algorithm :) great vid!

    • @hoangnguyendinh1107
      @hoangnguyendinh1107 ปีที่แล้ว +1

      They add the concept of virtual nodes mean multiple virtual nodes are associated with one physical node and are distributed along the hash ring. Hence it may reduce the uneven distribution of moving data.

    • @anthonyoleinik6472
      @anthonyoleinik6472 ปีที่แล้ว

      @@hoangnguyendinh1107 That is very very clever! I could see how that solves the problem. Thanks!

  • @SocialTransmission
    @SocialTransmission ปีที่แล้ว

    Does introducing a new server in your example not result result in the load being unevenly distributed? With 4 nodes, each node is receiving an equal proportion of the total range 0-360. Adding a node between S0 and S90 means that the range between S270 and S90 is served by 3 nodes while the rest of the hash range is still served by 2 nodes. It sounds like one needs to add 4 new nodes to get an even distribution of load.

    • @fedefede843
      @fedefede843 8 หลายเดือนก่อน

      The most common way to mitigate this is using more than one hash function for the servers. A good value could be log(M), where M is the max number in the circle, in this case 360. This way you "ensure" the are not big chunks without a server in the circle and keys get distributed uniformly. Off course you pay the price of complexity, and when remove/add a server, you need to reallocate log(M) times. Cheers!

  • @AhmedMahmoud-wz6du
    @AhmedMahmoud-wz6du ปีที่แล้ว

    wow

  • @5590priyank
    @5590priyank ปีที่แล้ว

    when we add a new server, rather than new server talking to next server to transfer keys, how about it gets populated lazily as and when cache miss happens

  • @danku1013
    @danku1013 ปีที่แล้ว

    If you really think about it, that's not only about system design but also some algorithmic stuff that many people hate on the coding interviews.
    Please make more videos related to system design, there are a lot of interesting things(you probably covered most of them ahaha).
    I was nostalgic watching this video if you know what I mean. 😊

  • @sachinchauhan6489
    @sachinchauhan6489 ปีที่แล้ว

    Rendezvous hashing is more simple than consistent hashing and solves the same problem. But there are other tradeoffs.

  • @panixx8289
    @panixx8289 ปีที่แล้ว +1

    Another problem is that data load not evenly distributed if many servers are close on the ring

    • @hnasr
      @hnasr  ปีที่แล้ว

      Right! Hot spots.

    • @fedefede843
      @fedefede843 8 หลายเดือนก่อน

      ​@@hnasr a way to mitigate that is to have multiple hash functions for the servers.Cheers!

  • @BlagiwRoblox
    @BlagiwRoblox ปีที่แล้ว

    this is like a HEX

  • @WeilongYou
    @WeilongYou ปีที่แล้ว

    So this video doesn't discussion V-Nodes yet?

  • @BlagiwRoblox
    @BlagiwRoblox ปีที่แล้ว

    Somebody shall ping the data number destribution when have an issue there you can't guess on that or just turn a script look for every single one in the array do there can be said upgrade to that do I can't spoil it, bc it is coming 👍

  • @sathvikreddy5799
    @sathvikreddy5799 ปีที่แล้ว

    Hussein I am a fan. Please pin this comment.

  • @BlagiwRoblox
    @BlagiwRoblox ปีที่แล้ว

    and then we play endless snake that consume more and more trouble how we explain it XD

  • @PGinPublic
    @PGinPublic ปีที่แล้ว

    first

    • @parasite6731
      @parasite6731 ปีที่แล้ว +1

      🎖️this for your
      Now enjoy

  • @krishnabirla16
    @krishnabirla16 ปีที่แล้ว

    Expected a better explanation. Expect a long follow up video.