# Consistent hashing

⚡️ Tags: 📍Comparison 📍NoSQL 📍DistributedSystem

Consistent Hashing is a distributed hashing scheme that operates independently of the number of servers or objects in a distributed hash table. It powers many high-traffic dynamic websites and web applications.

# How Does Consistent Hashing Work?

At a high level, consistent hashing performs the following operations:

  1. The output of the hash function is placed on a virtual ring structure (known as the hash ring)
  2. The hashed IP addresses of the nodes are used to assign a position for the nodes on the hash ring
  3. The key of a data object is hashed using the same hash function to find the position of the key on the hash ring
  4. The hash ring is traversed in the clockwise direction starting from the position of the key until a node is found
  5. The data object is stored or retrieved from the node that was found

Read more: Consistent Hashing Algorithm (opens new window)

# Consistent Hashing vs Hash Slot

Redis Cluster => Hash Slot 16384 slots

Cassandra Consistent Hashing => fROM -263 to 263 - 1

Virtual nodes is quite simalar with hash slot.

But virtual nodes is not an original concept of consistent hashing, but more like a trick used by Cassandra based on consistent hashing. So it's also ok for redis to say not using consistent hashing.

So, don't bother with phraseology.

Readmore:

# Refs