0

I am using DCAwareRoundRobinPolicy for my cassandra connection. But the time taken for querying by my driver is comparatively larger than when i am using the same connection parameters in php.

The datastax driver in php uses the function to the the same:

withDatacenterAwareRoundRobinLoadBalancingPolicy(
   string $localDatacenter, int $hostPerRemoteDatacenter, 
   bool $useRemoteDatacenterForLocalConsistencies )

When the last parameter is set as false, only local hosts are used for querying. But this parameter setting is not available in gocql driver. And I am guessing that this may be causing the issue I am facing. Correct me if I am wrong.

Please help in this regard what can be done.

I was not facing this issue when I had only 1 node in cluster.

For nodetool status :

Datacenter: DC1

Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
-- Address Load Tokens Owns Host ID Rack
UN 206.* 298.89 GB 1 ? de58dea3-7d16-4318-8549-a34d42aa3d65 RAC1
UN 206.* 287.63 GB 1 ? b312ce3d-c23f-476e-9396-3f8ec2219425 RAC1
UN 206.* 280.08 GB 1 ? c82f1f90-bca6-4438-bc43-68bf370a555a RAC1
UN 206.* 260.61 GB 1 ? 95b33f1f-d282-42ea-974b-987552932535 RAC1
UN 206.* 301.05 GB 1 ? 4725e34f-9368-4c18-85ef-6cd96352b73e RAC1

Datacenter: DC3

Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
-- Address Load Tokens Owns Host ID Rack
UN 173.* 262.16 GB 256 ? 283afa18-d085-4ff0-b410-e0f5fd368669 RAC1
UN 173.* 292.17 GB 256 ? b59a0d6c-2f77-4912-a0ad-eae3687aabbc RAC1
UN 173.* 253.07 GB 256 ? 44b6e01a-f6f1-471c-95a2-ff66f6188438 RAC1
UN 173.* 281.6 GB 256 ? 43d1a656-5aeb-42a9-bfee-c11f1a0a76dc RAC1
UN 173.* 250.6 GB 256 ? ceb40080-012c-4446-8a6b-220ffa472ddc RAC1
Alex Ott
  • 80,552
  • 8
  • 87
  • 132
Nupur Bansal
  • 21
  • 1
  • 3
  • Can you share some details on the cluster configuration? Output of "nodetool status" command would do. Also what is the consistency level with which you are querying? "local_quorum" vs "quorum"? – dilsingi Aug 12 '17 at 16:05
  • Hi @dilsingi, For nodetool status : Datacenter: DC1 Status=Up/Down |/ State=Normal/Leaving/Joining/Moving -- Address Load Tokens Owns Host ID Rack UN 206.* 298.89 GB 1 ? de58dea3-7d16-4318-8549-a34d42aa3d65 RAC1 UN 206.* 287.63 GB 1 ? b312ce3d-c23f-476e-9396-3f8ec2219425 RAC1 UN 206.* 280.08 GB 1 ? c82f1f90-bca6-4438-bc43-68bf370a555a RAC1 UN 206.* 260.61 GB 1 ? 95b33f1f-d282-42ea-974b-987552932535 RAC1 UN 206.* 301.05 GB 1 ? 4725e34f-9368-4c18-85ef-6cd96352b73e RAC1 – Nupur Bansal Aug 16 '17 at 10:17
  • consistency level I am using is Local_one – Nupur Bansal Aug 16 '17 at 10:17
  • You have only one DC in the cluster. So the localDatacenter setting doesn't add any value at present. Its useful when you have multiple datacenter and you want connect to only one amongst them. Now what does the query look like and how do you determine its slow? Add the query response time and the table structure. – dilsingi Aug 16 '17 at 22:01
  • No I have 2 data centers.This is for the 2nd one. Datacenter: DC3 Status=Up/Down |/ State=Normal/Leaving/Joining/Moving -- Address Load Tokens Owns Host ID Rack UN 173.* 262.16 GB 256 ? 283afa18-d085-4ff0-b410-e0f5fd368669 RAC1 UN 173.* 292.17 GB 256 ? b59a0d6c-2f77-4912-a0ad-eae3687aabbc RAC1 UN 173.* 253.07 GB 256 ? 44b6e01a-f6f1-471c-95a2-ff66f6188438 RAC1 UN 173.* 281.6 GB 256 ? 43d1a656-5aeb-42a9-bfee-c11f1a0a76dc RAC1 UN 173.* 250.6 GB 256 ? ceb40080-012c-4446-8a6b-220ffa472ddc RAC1 – Nupur Bansal Aug 17 '17 at 04:07
  • Can you add the complete nodetool status output in your original question. It's confusing with partial answers – dilsingi Aug 17 '17 at 04:21
  • I have updated the question – Nupur Bansal Aug 18 '17 at 11:02
  • @dilsingi any suggestions?? – Nupur Bansal Aug 28 '17 at 04:20

1 Answers1

0

I was having similar issue, but by forcing nodes from local DC to contact on LOCAL DC nodes; I was able to fix this for me.

You can force nodes to contact local DC nodes first by setting the the localDC to name of localDC & add the contact points also from local DC.

DCAwareRoundRobinPolicy.builder().withLocalDc(getLocalDC());

StringTokenizer tokenizer = new StringTokenizer(getCassandraHostsOfLocalDC().trim(),",");
while(tokenizer.hasMoreElements()){
    contactPoints.add(tokenizer.nextToken().trim());
}
builder.addContactPoints(contactPoints.toArray(new String[0]));
Anil Kapoor
  • 644
  • 6
  • 19