Fetching a random replica with Java client


#1

Hi, I have some records in my database which can be considered as hot-spots, so I would like to store them in a separate namespace (probably in-memory), set the replication factor equal to the number of nodes in the server, and fetch a random replica instead of the master so I can spread the load.

Is that possible with the Java client and if so, what parameters do I need to change?

Thank you in advance!


#2

It’s not currently possible to direct a read command to a random node. We will look into adding a new “Policy.readTarget” variable in the next java client release.


#3

Java client 3.1.1 has been released which allows you to fetch from a random node:

 Policy.replica = Replica.RANDOM;

#4

Thanks for the update Brian! Cheers


#5

Just a quick check, on the Java client release notes it says the feature is available for Aerospike server versions >= 3.5.9. Since the latest version is 3.5.8, is this just a typo or should I actually wait for a next version?

Thanks again!


#6

You are not dependent on the server version to use Replica.RANDOM… RANDOM works because you don’t need prole maps to get a random node.

Servers versions >= 3.5.9 are required to use Replica.MASTER_PROLES because the prole maps are required in this case. These maps are only available in servers >= 3.5.9 (which will be released soon).