Hazelcast 3.4 'max-size' attribute of hazelcast IMap is not working correctly

7.2k Views Asked by At

I am using hazelcast-spring-3.1.xsd. My hazelcast map configuration is given below.

<hz:map name="defaultMap"
                    backup-count="1"
                    max-size="5000"
                    max-size-policy = "PER_NODE"
                    eviction-percentage="50"
                    read-backup-data="true"    
                    eviction-policy="LRU"
                    merge-policy=
                        "com.hazelcast.map.merge.LatestUpdateMapMergePolicy"
                    time-to-live-seconds="0"
                >

I have given max-size = 5000. I have 12000 records and defaultMap is loading 12000 records in it if i do insert into it. I am confused here ,how it can load more data than its actual size 5000. I am getting no exception in inserting 12000 data records.

And one more thing its eviction configuration is not working also. I want to evict my cache by 50 percent if it reaches its max-size limit.

Can any body help me? Its very urgent.What i am missing ?

3

There are 3 best solutions below

1
On BEST ANSWER

You have max-size-policy = "PER_NODE" setting which means maximum number of map entries in each Hazelcast instance, not the whole Hazelcast cluster (or the whole map).

In Hazelcast 2.x releases, the default value for max-size eviction policy was cluster_wide_map_size. In 3.x releases, it is replaced with PER_NODE.

There are other settings as well. For detailed map eviction settings and examples, you can check this out.

0
On

LFU: Least Frequently Used LRU:Least Recently Used NONE:None RANDOM:Randomly I think You would have used LRU instead of LFU..

1
On

You can use this property to resolve your issue:

eviction-policy="LFU"