You can calculate the amount of memory and partitions needed for your specific configuration.
To size the memory that you need, load your application data into a single JVM. When the heap usage reaches 60%, note the number of objects that are used. This number is the maximum recommended object count for each of your Java virtual machines. To get the most accurate sizing, use realistic data and include any defined indexes in your sizing because indexes also consume memory. The best way to size memory use is to run garbage collection verbosegc output because this output gives you the numbers after garbage collection. You can query the heap usage at any given point through MBeans or programmatically, but those queries give you only a current snapshot of the heap, which might include uncollected garbage, so using that method is not an accurate indication of the consumed memory.
numShardsPerPartition = 1 + total_number_of_replicas
Number of Java virtual machines (minNumJVMs value)
To scale up your configuration, first decide on the maximum number of objects that need to be stored in total. To determine the number of Java virtual machines you need, use the following formula:minNumJVMS=(numShardsPerPartition * numObjs) / numObjsPerJVMRound this value up to the nearest integer value.
Number of shards (numShards value)
At the final growth size, 10 shards for each JVM should be used. As described before, each JVM has one primary shard and (N-1) shards for the replicas, or in this case, 9 replicas. Because you already have a number of Java virtual machines to store the data, you can multiply the number of Java virtual machines by 10 to determine the number of shards:numShards = minNumJVMs * 10 shards/JVM
Number of partitions
If a partition has one primary shard and one replica shard, then the partition has two shards (primary and replica). The number of partitions is the shard count divided by 2, rounded up to the nearest prime number. If the partition has a primary and two replicas, then the number of partitions is the shard count divided by 3, rounded up to the nearest prime number.numPartitions = numShards / numShardsPerPartition
Starting configuration
Based on the previous calculations, you would start with 250 Java virtual machines and grow toward 500 Java virtual machines over 5 years, which allows you to manage incremental growth until you arrive at the final number of entries.In this configuation, about 200,000 entries are stored per partition (500 million entries divided by 2503 partitions). You should set the numberOfBuckets parameter on the map that holds the entries to the closest higher prime number, in this example 70887, which keeps the ratio around 3.
When the maximum number of Java virtual machines is reached
When you reach your maximum number of 500 Java virtual machines, you can still grow your grid. As the number of Java virtual machines grows beyond 500, the shard count begins to drop below 10 for each JVM, which is below the recommended number. The shards start to become larger, which can cause problems. You should repeat the sizing process considering future growth again, and reset the partition count. This practice requires a full grid restart, or an outage of your grid.