|Developing with Pivotal GemFire / Partitioned Regions|
Decide how many buckets to assign to your partitioned region and set the configuration accordingly.
The total number of buckets for the partitioned region determines the granularity of data storage and thus how evenly the data can be distributed. Pivotal GemFire distributes the buckets as evenly as possible across the data stores. The number of buckets is fixed after region creation.
<region name="PR1"> <region-attributes refid="PARTITION"> <partition-attributes total-num-buckets="7"/> </region-attributes> </region>
RegionFactory rf = cache.createRegionFactory(RegionShortcut.PARTITION); rf.setPartitionAttributes(new PartitionAttributesFactory().setTotalNumBuckets(7).create()); custRegion = rf.create("customer");
You are trying to avoid the situation where some members have significantly more data entries than others. For example, compare the next two figures. This figure shows a region with three data stores and seven buckets. If all the entries are accessed at about the same rate, this configuration creates a hot spot in member M3, which has about fifty percent more data than the other data stores. M3 is likely to be a slow receiver and potential point of failure.
Configuring more buckets gives you fewer entries in a bucket and a more balanced data distribution. This figure uses the same data as before but increases the number of buckets to 13. Now the data entries are distributed more evenly.