Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

hazelcast

I just went through the hazelcast documentation.

It suggests that data partitioned across all the nodes.

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

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

like image 317
Rakesh Waghela Avatar asked May 11 '13 12:05

Rakesh Waghela


People also ask

What is Hazelcast partition?

Hazelcast distributes key objects into partitions (blocks) using a consistent hashing algorithm and those partitions are assigned to nodes. That means an entry is stored in a node which is owner of partition to that entry's key is assigned.

Does Hazelcast use UDP?

In Unified Intelligence Center, the default mechanism for Hazelcast cluster discovery or formation is UDP multicast. Unified Intelligence Center uses the Multicast group IP address 224.2.2.3 and port 54327.


1 Answers

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.

like image 142
Fuad Malikov Avatar answered Sep 19 '22 14:09

Fuad Malikov