does redis cluster use consistent hashing
Asked Answered
M

2

11

I'm using redis cluster 3.0.1.

I think redis cluster use consistent hashing. The hash slots are similar to virtual nodes in consistent hashing. Cassandra's data distribution is almost the same as redis cluster, and this article said it's consistent hashing.

But the redis cluster turorial said redis cluster does not use consistent hash.

What do I miss? Thanks.

Mafaldamafeking answered 9/5, 2018 at 6:24 Comment(0)
C
7

You are right, 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.

Cellulose answered 9/5, 2018 at 10:28 Comment(0)
A
0

Consistent hashing gives a lot of nice properties when it hashes servers into a ring:

  1. servers are randomly distributed in the ring, good for balancing load in a cluster
  2. add/remove a server only affect its neighbors, minimize data migration

However, I don't think you can control which key goes to which server: i.e. I can't do the following assignment:

key 1-99 ==> serverA
key 100 ==> serverB

// I can probably reach the same traffic split, 99:1 
// by given more virtual nodes to serverA, but it won't guarantee
// key 1 and key 99 is served by the same machine 

This is allowed in redis, redis uses hash slot, which I believe is an explicit map from hash value -> severs. This gives you full control, especially it enables multi-key transaction: i.e.

key Alice, key Bob ==> serverA
// move 100$ from Alice's bank account to Bob's in one operation
// no need special technique like 2 phase commit

The key -> server mapping is now managed by yourself as opposed to by consistent hashing, the drawback is that there are more work/responsibility for the admins, Redis also provides commends to help you with the management: rebalance, reshard

Disclaimer: this is my own understanding (here's my sources), I wish I can just @redis_dev on stackoverflow and let them proofread my answer

Aeolian answered 6/12, 2021 at 2:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.