rack-awareness is supported in Java Client. Where can I find documentation regarding how to use the feature? In particular, how does a client specify which rack id it prefers to connect?
Secondly, with client rack-awareness, does the client read data from masters as well as replicas in the specified rack?
To clarify the question, consider an example of 2 racks and replication factor of 2, each rack will have masters for half the data and replicas for the other half of the data. My understanding is that normally only the masters are read from, and replicas are used only for rebalance when its master goes down. i.e. replicas are never read from.
If client rack-awareness implies that a client always reads all data from the same rack, does that mean it reads from the masters as well as replicas?
You need to define the client rack id manually. When your app comes up in rack X it needs to define that in the clientpolicy before connecting to Aerospike myClientPolicy.rackId=<x>.
With these optimizations you can tell the client to prefer to only read from the local rack. It won’t have to consult both master/replica unless you define it that way.
So if you have two racks, you will be reading from the same rack 100% of the time with this feature but reading only the replica 50% of the time in theory.
I’m not sure if there is any way to find this, outside of monitoring the network. If you’re paying for cross-AZ traffic like in AWS, you could find this data pretty easily. Someone else in the forum might know a good way though…
Set up two racks with replication factor 2. Write 100K records to the cluster and then read with a preferred rack. Assuming no ongoing migrations, all of the reads should then occur on the same rack.