Overflow in Hazelcast Queue Store
One of the new features of Hazelcast 3 is the queue store.
Differently from map store; overflow is possible. If you set a memory Iimit; it starts persisting to disk and skipping the memory when queue reaches this limit.
Here the configuration:
<queue-store> <class-name>com.hazelcast.QueueStoreImpl</class-name> <properties> <property name="binary">false</property> <property name="memory-limit">1000</property> <property name="bulk-load">500</property> </properties> </queue-store>
For above configuration:
- Items will be persisted in their Object form (deserialized one).
- If the size of the queue has reached 1000 (memory-limit), next element will be just persisted to disk it will not be stored in memory.
- Items will be loaded from store in bulks with size 500.
Some more notes:
- Use memory-limit when you avoid over-usage of RAM in case of high load.
- If you want all items in memory (and store) use Integer.MAX_VALUE, if you want all items just in store then use 0 as memory-limit.
- If you do not reach the store externally (just hazelcast uses the store) then make the binary configuration to true. That will increase the performance as a step for deserialization will be skipped.
Here you can see some examples of QueueStore implementation: