1
votes

When in Java, I create a Cassandra cluster builder, I provide a list of multiple Cassandra nodes as shown below:

Cluster cluster = Cluster.builder().addContactPoint(host1, host2, host3, host4).build();

But from what I understand, the connector connects only to the first host in the list that is available, and that host becomes my connection point to the Cassandra cluster.

Now, my question is if my Java application reads/writes huge amount of data from/to Cassandra, then doesn't my Java application overwhelm the node that it is connected to?

Is there a way to configure my connection such that it uses multiple nodes of Cassandra for its reads/writes? What is the common practice?

1

1 Answers

1
votes

It uses the contact point to find the rest of the nodes in the cluster, then creates a pool of connections to all the hosts and balances the requests among them. It doesn't only connect to the hosts you provide unless you use the whitelist load balancing policy or a custom one.

If your worried about overwhelming nodes use the RoundRobinLoadBalancingPolicy (DC aware if multiple DCs) and it will distribute it amongst all of them evenly. If you have hot spots of data and use the TokenAware policy you may have it uneven, but you shouldn't need to worry about it.