From c09fd080b1022d0580574f8b2af17251de197cdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20B=C4=85czkowski?= Date: Tue, 19 Nov 2024 10:29:22 +0100 Subject: [PATCH] Switch to `ReplicaOrdering.RANDOM` for select LBPs This setting has the benefit of evenly distributing the load across replicas. Using round robin policies with `NEUTRAL` ordering can easily lead to spikes in load on singular nodes during cluster grow and uneven workload afterwards when using tablets. The reason for not switching to `RANDOM` for rack aware LBP right now is that it is slightly broken in that configuration. See java-driver/369. --- .../org/apache/cassandra/stress/util/JavaDriverClient.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/stress/src/org/apache/cassandra/stress/util/JavaDriverClient.java b/tools/stress/src/org/apache/cassandra/stress/util/JavaDriverClient.java index 05dacecbda..76031278fd 100644 --- a/tools/stress/src/org/apache/cassandra/stress/util/JavaDriverClient.java +++ b/tools/stress/src/org/apache/cassandra/stress/util/JavaDriverClient.java @@ -103,6 +103,7 @@ public JavaDriverClient(StressSettings settings, List hosts, int port, E private LoadBalancingPolicy loadBalancingPolicy(StressSettings settings) { LoadBalancingPolicy ret = null; + ReplicaOrdering replicaOrdering = null; if (settings.node.rack != null) { RackAwareRoundRobinPolicy.Builder policyBuilder = RackAwareRoundRobinPolicy.builder(); @@ -110,15 +111,17 @@ private LoadBalancingPolicy loadBalancingPolicy(StressSettings settings) policyBuilder.withLocalDc(settings.node.datacenter); policyBuilder = policyBuilder.withLocalRack(settings.node.rack); ret = policyBuilder.build(); + replicaOrdering = ReplicaOrdering.NEUTRAL; } else { DCAwareRoundRobinPolicy.Builder policyBuilder = DCAwareRoundRobinPolicy.builder(); if (settings.node.datacenter != null) policyBuilder.withLocalDc(settings.node.datacenter); ret = policyBuilder.build(); + replicaOrdering = ReplicaOrdering.RANDOM; } if (settings.node.isWhiteList) ret = new WhiteListPolicy(ret, settings.node.resolveAll(settings.port.nativePort)); - return new TokenAwarePolicy(ret, ReplicaOrdering.NEUTRAL); + return new TokenAwarePolicy(ret, replicaOrdering); } public PreparedStatement prepare(String query)