Anurag Rana
Anurag Rana

Reputation: 1466

percentagewise load balancing in java microservice to Cassandra

I am using a Cassandra cluster with 4 nodes. 2 nodes have much more resources than the other two in terms of CPU cores and RAM.

Right now I am using the DCAwareRoundRobin load balancing policy. I believe in this policy, all nodes receive the same number of requests. Due to this, 2 smaller nodes are NOT performing well. This is resulting in high IO and CPU usage on smaller nodes.

I want to distribute the traffic from the Java application to the Cassandra cluster in the ratio of available resources.

For example: small node 1 - 20%, small node 2 - 20%, large node 1 - 30%, large node 2 - 30% of queries.

Need you suggestion about any method or approach I can use to distribute the traffic in the manner.

I understand that I can use LatencyAwarePolicy [1]. I am worried that when a node is taken out of query plan due to a threshold breach, the remaining nodes might see the ripple effect.

[1] https://docs.datastax.com/en/drivers/java/2.2/com/datastax/driver/core/policies/LatencyAwarePolicy.html

Upvotes: 0

Views: 46

Answers (1)

Hades Architect
Hades Architect

Reputation: 153

In short, the approach you have is an anti-pattern and should be avoided at all costs.

TL;DR: Make the nodes the same.

During the request processing, The query will reach not a single node but all the nodes responsible for the partition you are accessing, based on the Replication Factor, doesn't matter whatever Consistency Level you use. If you have RF=3, 3 of your 4 nodes will be reached for each write or read request. You do not have and should not have control over request distribution, "the medicine will be worse than the sickness".

Upvotes: 2

Related Questions