Bringing together the Apache Cassandra experts from the community and DataStax.

Want to learn? Have a question? Want to share your expertise? You are in the right place!

Not sure where to begin? Getting Started

 

question

bensmail avatar image
bensmail asked Erick Ramirez answered

How can I configure my app to access a random coordinator?

Hello, We have a DSE cluster on GCP.

How can I configure the list of the Nodes on application side so I can access randomly to the cluster to different coordinator Nodes (Not the same cordinator at each Query)?

In which case should I setup the GCP Cluster Load balancing in this context?

Regards, Bensmail Salah

load balancing
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Erick Ramirez avatar image
Erick Ramirez answered

The Cassandra drivers do this automatically for you. The drivers use a built-in load-balancing policy that is aware of the cluster topology plus the health of the nodes.

For example if you are using the Java driver, by default it uses a load-balancing policy that routes queries to the local data centre with a token-aware policy that prefers to route requests to replicas (nodes) that own the data being queried.

For each client request, the configured load balancing policy (LBP) computes what's called a query plan which determines:

  • the nodes the driver will communicate with,
  • which coordinator to pick and which nodes to use as failover.

The list of nodes in the query plan is different for each query so the load is balanced across nodes in the cluster and only contains available nodes -- nodes which are down or unresponsive are not included in the query plan. For more info, see the Java driver document on Load balancing.

If you're new to developing apps for Cassandra, we recommend having a look at the free developer resources at datastax.com/dev. This short interactive tutorial for the Java driver will show you how to do CRUD operations. Cheers!

Share
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.