Carl H
Carl H

Reputation: 405

Why redis cluster only have 16384 slots?

In my opinion, with the development of keys, the 'hash conflict' will occurs more and more frequently. I have no idea if those keys on the same slot are stored in singly linked list, then read performance will be effected, especially the stale record?

Upvotes: 5

Views: 4421

Answers (2)

Jim Dennis
Jim Dennis

Reputation: 17510

These "slots" are merely a unit of distribution across shards. You're not going to have of 16K shards servers in a cluster; but they are granular enough to allow some degree of weighted load distribution. (For example if you start with four shard on one type of hardware and choose to introduce two more of a more power profile, you could make the new servers targets for twice as many slots as the existing servers and thus achieve a more relatively even utilization of your capacity.

I'm just summarizing the gist of how they're used. For details read the Redis Cluster Specification.

Upvotes: 2

ponypaver
ponypaver

Reputation: 397

answer from antirez, the author of Redis, below.

The reason is:

  • Normal heartbeat packets carry the full configuration of a node, that can be replaced in an idempotent way with the old in order to update an old config. This means they contain the slots configuration for a node, in raw form, that uses 2k of space with16k slots, but would use a prohibitive 8k of space using 65k slots.
  • At the same time it is unlikely that Redis Cluster would scale to more than 1000 mater nodes because of other design tradeoffs.

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.

Upvotes: 4

Related Questions