为什么hazelcast的默认分区数为271,选择一个的参数是什么? [英] Why hazelcast has default partition count of 271 and what are the parameters to chose one?

查看:222
本文介绍了为什么hazelcast的默认分区数为271,选择一个的参数是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚浏览了hazelcast文档.

I just went through the hazelcast documentation.

这表明数据已在所有节点上分区.

It suggests that data partitioned across all the nodes.

以及默认情况下在群集271中创建的分区数!

And the number of partitions created in cluster 271 by default !

哪些参数控制着正确的分区计数值的选择.为什么默认分区数为271?

What parameters govern the selection of right partition count value. And why default partition count is 271 ?

推荐答案

271是素数.并给定任何密钥,Hazelcast将对该密钥进行哈希处理并使用分区计数对其进行修改.在这种情况下,质数被认为会产生更多的伪随机结果.实际上,从用户角度看,启动它并不是那么重要.

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.

然后您可能会问,为什么选择271,而不是其他素数.

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

仅因为271是一个很好的数字,当节点少于100个时,它将几乎均匀地分布.当您有超过100个节点时,您需要增加它以使分布均匀.

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.

增加分区数量的另一个原因是当您有大量数据时.假设您有300 GB的数据要存储在数据网格中.然后,每个分区将超过1GB,迁移将花费太长时间.请注意,在迁移过程中,对该分区的所有更新均被阻止.为了避免延迟,您希望每个分区都有少量数据.因此,将其增加到足以适应移动分区延迟的数量.

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.

这篇关于为什么hazelcast的默认分区数为271,选择一个的参数是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆