hazelcast - read-backup-data vs near cache

2019-08-21 10:11发布

问题:

In IMap configuration there is an attribute read-backup-data that can be set as true which enables a member to read the value from the backup copy, if available, in case the owner of the key is some other member.

http://docs.hazelcast.org/docs/latest-development/manual/html/Distributed_Data_Structures/Map/Backing_Up_Maps.html#page_Enabling+Backup+Reads

Then there is nearcache which will start caching results for a few datastructures locally.

http://docs.hazelcast.org/docs/latest-development/manual/html/Performance/Near_Cache/Hazelcast_Data_Structures_with_Near_Cache_Support.html

If we have 2 kinds of cluster setup:

  1. 2 members, and async-backup-count for a map is 1, and read-backup-data is true
  2. 2 members, nearcache enabled for this map

Would there be differences in these 2 approaches?

1st setup will probably use less memory, and will not be configurable. But in terms of read performance?

回答1:

For two member cluster setup; enabling backup reads will provide you to access all the data locally, since both members hold all the entries as either primary or backup. This setup is not much different than using a Replicated Map (see here for details: http://docs.hazelcast.org/docs/latest-development/manual/html/Distributed_Data_Structures/Replicated_Map.html). So; when your cluster have only two members (also no clients), enabling backup reads can be more advantageous in terms of performance.

However; near cache has a bunch of configuration options, and you can decide how much data you need to access locally at any type of setup (including client-server topology). You can also decide the in-memory data format in near cache. These options can provide you more performance than enabling backup reads.

Both options are not so much different in single entry read performance (I assume near cache contains valid entry), since both don't perform a remote operation.