Client rack awareness

#1

As per this thread,

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?

Thanks.

#2

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>.

https://www.aerospike.com/apidocs/java/com/aerospike/client/policy/ClientPolicy.html#rackAware https://www.aerospike.com/apidocs/java/com/aerospike/client/policy/ClientPolicy.html#rackId

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.

Additionally, even without rack awareness its possible to tell Aerospike to consult replica’s for reads. See https://www.aerospike.com/docs/guide/policies.html#replica

2 Likes
#3

Thank you @Albot

Once a client has been setup for rack awareness, how would I test/verify that it performed the operation against the same rack?

#4

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…

#5

Shouldn’t be too hard.

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.

#6

@kporter thanks for your response.

Assuming no ongoing migrations, all of the reads should then occur on the same rack.

That is my question. How I can tell if all the reads did occur on the same rack?

#7

Check https://www.aerospike.com/docs/reference/metrics/#client_read_success.

#8

Thanks @Albot and @kporter for your help.

1 Like