Facing performance issue in Hazelcast with Client-Server Facing performance issue in Hazelcast with Client-Server kubernetes kubernetes

Facing performance issue in Hazelcast with Client-Server


The goal of a cache is to get the value from a key as fast as possible. In general, you already have the key, and request the value. That means you send a request to any node, this looks in the partition table which partition the key belongs to, and forwards the query to the relevant node.

In your second use-case, you try to get all keys from all nodes:

Set keys = map.keySet();Iterator iterator = keys.iterator();while (iterator.hasNext()) {    // doing stuff}

To return fast as possible, Hazelcast will return a lazy implementation of the Iterator. For each call to next(), it will need first to retrieve the key following the above process. Plus, I assume the // doing stuff code actually loads the value from the key.

In conclusion, please avoid at all costs using map.keySet(). Unless I know more about your context and your use-case, I unfortunately cannot provide with a relevant alternative.


Finally I managed to get my performance with some tweak. I had common code to put data into cache and access data from cache. What I did is before putting data into final map, I added one more dummy key "ALL". So when My data is being access I always retrieve data from ALL key and then iterate over it. Though it is not a proper solution but managed to save lot of efforts. Posting this as an answer, might be useful for others who are in same situation.

Thanks all for sparing time and helping me out for possible options.