- Getting Started with Hazelcast
- Mat Johns
- 536字
- 2021-08-06 16:56:52
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.
- Oracle Exadata性能優化
- C++ Builder 6.0下OpenGL編程技術
- Mastering Entity Framework
- 看透JavaScript:原理、方法與實踐
- Hands-On JavaScript High Performance
- Reactive Programming With Java 9
- 自制編程語言
- Go并發編程實戰
- Spring+Spring MVC+MyBatis整合開發實戰
- Teaching with Google Classroom
- Flutter跨平臺開發入門與實戰
- 計算機應用基礎案例教程
- “笨辦法”學C語言
- Bootstrap for Rails
- Scala Functional Programming Patterns