Why hazelcast has default partition count of 271 and what are the parameters to chose one?

前端 未结 1 1943
生来不讨喜
生来不讨喜 2021-01-05 08:10

I just went through the hazelcast documentation.

It suggests that data partitioned across all the nodes.

And the number of partitions created in cluster 27

相关标签:
1条回答
  • 2021-01-05 08:49

    271 is a prime number. And given any key, Hazelcast will hash the key and mod it with the partition count. In this context, prime numbers are believed to generate more pseudo-random result. Actually for user perspective, it is not that important to have it prime.

    Then you may ask, why 271 but not other prime number.

    Simply because 271 is a good number that will almost evenly distribute when you have less than 100 nodes. When you have more than 100 nodes, you need to increase it to make the distribution even.

    Another reason to increase partition count is when you have large amount of data. Say you have 300 GB of data to be stored in data grid. Then each partition will have over 1GB and migration will take too long. Note that during migration, all updates to that partition are blocked. For sake of latency, you would like to have small data per partition. So increase it to a number where you are comfortable with the latency of moving partitions.

    Note that partitions will migrate only when you add a new node.

    0 讨论(0)
提交回复
热议问题