# Fetching a random replica with Java client

**URL:** <https://discuss.aerospike.com/t/fetching-a-random-replica-with-java-client/1095>\
**Category:** Java Client\
**Created:** [March 25, 2015, 4:38am UTC](https://discuss.aerospike.com/t/fetching-a-random-replica-with-java-client/1095 "2015-03-25T04:38:10Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ikounakis](https://avatars.discourse-cdn.com/v4/letter/i/e79b87/32.png) [@ikounakis](https://discuss.aerospike.com/u/ikounakis)\
**Post date:** [March 25, 2015, 4:38am UTC](https://discuss.aerospike.com/t/fetching-a-random-replica-with-java-client/1095/1 "2015-03-25T04:38:10Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Brian](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/brian/32/2211_2.png) [@Brian](https://discuss.aerospike.com/u/Brian)\
**Post date:** [March 28, 2015, 1:06am UTC](https://discuss.aerospike.com/t/fetching-a-random-replica-with-java-client/1095/2 "2015-03-28T01:06:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Brian](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/brian/32/2211_2.png) [@Brian](https://discuss.aerospike.com/u/Brian)\
**Post date:** [April 16, 2015, 1:25am UTC](https://discuss.aerospike.com/t/fetching-a-random-replica-with-java-client/1095/3 "2015-04-16T01:25:37Z")

</div>

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

```
 Policy.replica = Replica.RANDOM;

```

---

<div class="post-metadata">

**Author:** ![ikounakis](https://avatars.discourse-cdn.com/v4/letter/i/e79b87/32.png) [@ikounakis](https://discuss.aerospike.com/u/ikounakis)\
**Post date:** [April 16, 2015, 2:04am UTC](https://discuss.aerospike.com/t/fetching-a-random-replica-with-java-client/1095/4 "2015-04-16T02:04:52Z")

</div>

Thanks for the update Brian! Cheers

---

<div class="post-metadata">

**Author:** ![ikounakis](https://avatars.discourse-cdn.com/v4/letter/i/e79b87/32.png) [@ikounakis](https://discuss.aerospike.com/u/ikounakis)\
**Post date:** [April 16, 2015, 2:38am UTC](https://discuss.aerospike.com/t/fetching-a-random-replica-with-java-client/1095/5 "2015-04-16T02:38:04Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Brian](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/brian/32/2211_2.png) [@Brian](https://discuss.aerospike.com/u/Brian)\
**Post date:** [April 16, 2015, 5:33am UTC](https://discuss.aerospike.com/t/fetching-a-random-replica-with-java-client/1095/6 "2015-04-16T05:33:49Z")

</div>

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