官术网_书友最值得收藏!

What happens when we reach our limits?

As large as we may scale our cluster to handle ever-growing datasets, it is quite possible that we will want to configure a map to feature specific behavior. The main things we can customize the number of backup counts and types, limits on how big a particular map can grow plus what we do when we reach that limit, and defining a default lifespan for our entries. We can use the hazelcast.xml configuration to define this behavior for all maps or for an individual one. Now, we can copy the configuration from the unpacked download bin/hazelcast.xml to our working directory, and add a custom configuration for our capitals map.

<map name="capitals">

  <max-size policy="cluster_wide_map_size">10</max-size>
  <eviction-policy>LFU</eviction-policy>
  <eviction-percentage>20</eviction-percentage>

  <backup-count>1</backup-count>
  <async-backup-count>1</async-backup-count>

  <time-to-live-seconds>86400</time-to-live-seconds>
  <max-idle-seconds>3600</max-idle-seconds>

</map>

The properties we have put in place should all be relatively self-explanatory, but let's go through them in a little more detail as there are a few that demand closer inspection.

The first set deals with bounding the size of the map and what to do when that limit is reached.

The max-size parameter as you would expect governs how big a map may grow before we have a clear out and evict existing entries for make room to potential future ones. However, we can additionally pick from five different types of policies to vary this behavior.

The first (and the default) policy is the easiest to understand.

  • cluster_wide_map_size
    • Maximum number of entries across the entire cluster

The second one is probably the least useful in a real world scenario.

  • partitions_wide_map_size
    • Maximum number of entries per internal partition slice
    • The number of partitions is also configurable, but as a cluster-wide parameter rather than specific to any one map

The latter three policies relate to the usage on an individual node basis.

  • max_size_per_jvm
    • Maximum number of entries per node
  • used_heap_size
    • Maximum heap usage in megabytes
  • used_heap_percentage
    • Maximum proportion of the total heap size

eviction-policy governs the strategy used to select entries to discard when making room for new ones; there are few options to pick from.

  • NONE
    • No eviction (default)
  • Least Recently Used (LRU)
    • The oldest interacted with the entries
  • Least Frequency Used (LFU)
    • The least interacted with the entries

eviction-percentage dictates when we trigger an eviction, and how much space we preemptively need to create relative to the overall max-size of the map.

The next set of configurations deal with backup copies of entries both in terms of number of duplicate copies to hold, but also the method and consistency of how they are created.

  • backup-count controls the number of backup copies created synchronously on each change. Increasing this number significantly will have performance implications as we will have to block waiting upon confirmations this many nodes.
  • async-backup-count controls the number of backup copies that are created asynchronously on a best effort basis. This figure combined with backup-count determines the total number of backup copies to be held.

The final set is used to set a map-wide default TTL for entries.

  • time-to-live-seconds is a default dumb TTL for each entry. Entities will be removed from the map after this amount of time, irrespective of use or resetting when overwritten.
  • max-idle-seconds sets the maximum time that an entry can sit unused before being expired.
主站蜘蛛池模板: 娄底市| 同德县| 盘山县| 丹寨县| 武平县| 宝鸡市| 青铜峡市| 怀柔区| 肇东市| 广东省| 东阿县| 台州市| 登封市| 房山区| 开平市| 蒙城县| 孝义市| 民县| 六盘水市| 苍南县| 巴彦县| 富平县| 石首市| 沙湾县| 友谊县| 深圳市| 南华县| 新绛县| 肇东市| 宣城市| 庆云县| 柘城县| 莱芜市| 威远县| 江源县| 福建省| 抚远县| 左云县| 东乌| 邢台市| 阳曲县|