New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
why redis-cluster use 16384 slots? #2576
Comments
The reason is:
So 16k was in the right range to ensure enough slots per master with a max of 1000 maters, but a small enough number to propagate the slot configuration as a raw bitmap easily. Note that in small clusters the bitmap would be hard to compress because when N is small the bitmap would have slots/N bits set that is a large percentage of bits set. |
Hey,i have two questions about you answer:
|
|
@foojolt thank you very much |
why: |
thx. The balance of bitmap's size and number of master is the key. |
what is other design tradeoffs? @foojolt |
8K bitmap size means that bitmap size is 8 bits? @foojolt |
How to understand the sentence not 65, that's 65K = 8 * 8 (8 bit/byte) * 1024 (1k) = 8K bitmap size?@foojolt |
crc16() can have 2^16 -1=65535, which means the bitmap has 65535 bits. so the size of the bitmap can be calculated by 65535 / 8 (8bit/byte)/1024(1k)=7.99 Kbytes. |
Thanks for answers |
Hi, I didn't find where to compress the slots bitmap in source code, did I miss something? |
No compression, just 1 bit for 1 slot. |
mark |
why 16k was in the right range to ensure enough slots per master with a max of 1000 maters? |
I think @antirez has already made it clear:
In a nutshell, it is the result of a balance between message size and average number of slots held by a master. |
mark |
Mark |
This is issue is quite old, yet I was asked this same question for so many times even after @antirez had already given his answer. Maybe it's the language gap. I think @antirez has already made it clear in English, and I don't want to be superfluous. Following is my understanding in Chinese: 需要注意2个问题: |
@trevor211 sorry, i still cannot understand it. why can't i use 1024 bit for 1000 masters, thus only 128Byte is needed. |
Mark. |
Mark |
1 similar comment
Mark |
Sorry for taking so long to reply. The thing is that if you allocate too few slots to a master, it would be impossible to migrate some keys to other masters. We may want to migrate hot keys to other nodes to alleviate the pressure on the server. As a consequence, it may be a better idea be able to allocate N slots to a single master, where N should not be too small or too big. |
mark. If use 1024 bit for 1000 master, then consistent hash will degenerate to normal hash. |
mark |
1 similar comment
mark |
mark |
1 similar comment
mark |
Why isn't slot 8192? |
m |
mark |
mark |
这是来自QQ邮箱的假期自动回复邮件。你好,我最近正在休假中,无法亲自回复你的邮件。我将在假期结束后,尽快给你回复。
|
why redis-cluster use 16384 slots? crc16() can have 2^16 -1=65535 different remainders。
The text was updated successfully, but these errors were encountered: