scylladb / cpp-driver

Scylla C/C++ Driver
25 stars 25 forks source link

Add rack-aware load balancing policy #73

Closed martin-sucha closed 1 year ago

martin-sucha commented 1 year ago

We need to prefer local rack as there are higher network costs when communicating with nodes in remote rack.

This policy prefers nodes from the local rack, then local datacenter and then other nodes.

The new RackAwarePolicy is similar to DCAwarePolicy, but does not have the deprecated options. TokenAwarePolicy and other code needed to be modified so that the local rack is propagated.

The TokenAware policy was changed to prefer replicas in remote rack / remote DC before trying non-replica nodes. It does not make much sense to not try the replicas and trying the replicas simplifies the code as now we have three levels local/remote/remote2.

This change might not be backwards-compatible, we don't know what exactly this project guarantees in terms of backwards compatibility.

Co-Authored-By: Peter Navrátil peter.navratil@kiwi.com

martin-sucha commented 1 year ago

See also https://github.com/datastax/cpp-driver/pull/536