Search code examples
network-programminghazelcastin-memory-database

How to set the local Hazelcast member as a preferred?


For example, we have 3 machines and each machine has 1 member and 1 client. To improve performance, I want that each client would send put/get requests to the local member first and only if there is no local member, it would communicate with other members in the cluster.

Does this make sense? And if yes, can we put "localhost" as a first member in the "hazelcast.xml" to achieve this?


Solution

  • If you are using Hazelcast Map, it is partitioned data structure so your primary data is partitioned across hazelcast members. Hazelcast Client is smart enough to figure out where this primary data is located and executes operation(READ,WRITE) on that hazelcast member. Therefore, connecting to local member does not add a big value in your use case.

    What you can use is Near Cache Feature to optimize your read operations.