Skip to content

Commit

Permalink
Switch to ReplicaOrdering.RANDOM for select LBPs
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Bouncheck committed Nov 19, 2024
1 parent 1be85b6 commit c09fd08
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -103,22 +103,25 @@ public JavaDriverClient(StressSettings settings, List<String> 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();
if (settings.node.datacenter != null)
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)
Expand Down

0 comments on commit c09fd08

Please sign in to comment.