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

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.
主站蜘蛛池模板: 营口市| 海原县| 邻水| 阳新县| 江川县| 叶城县| 南雄市| 江山市| 鄄城县| 冀州市| 饶阳县| 习水县| 庐江县| 沙田区| 建始县| 昌宁县| 铜山县| 甘孜县| 望江县| 高陵县| 河源市| 扎赉特旗| 三明市| 安义县| 渑池县| 凤翔县| 大关县| 肇庆市| 丰城市| 滨州市| 通许县| 天等县| 南澳县| 雷山县| 仙居县| 安平县| 萨嘎县| 潮安县| 岚皋县| 贺州市| 潼关县|