scylladb / scylla-rust-driver

Async CQL driver for Rust, optimized for ScyllaDB!
Apache License 2.0
583 stars 104 forks source link

Prefer the local DC for control connections #559

Open piodul opened 2 years ago

piodul commented 2 years ago

Currently, if the node which handled the control connection goes down, the driver will walk over the list of remaining nodes, in random order, sequentially trying to re-restablish the control connection until it manages to do it. However, this the random order does not consider DCs at all. While the latency of requests on control connection isn't too important, it would be nice if the schema/topology information didn't have to involve cross-DC traffic.

While we don't have a concept of a local DC in the Session (yet?), we can approximate it by assuming that the contact nodes are from the local DC. After establishing the first control connection, we should always prefer nodes from the DC of the first node.

mykaul commented 1 year ago

@avelanarius - need to get higher priority (than medium) to complete the gap on topology awareness

mykaul commented 1 year ago

@avelanarius - need to get higher priority (than medium) to complete the gap on topology awareness

@avelanarius - ping - let's ensure this get a priority - I see it may have missed 1.0.0?

mykaul commented 11 months ago

@avelanarius , @roydahan - ping - what's the latest here?

roydahan commented 11 months ago

With the current plan it will miss 1.0.0. If it's important enough (why? can you please give a background?), we can reconsider the plan or have it as part of 1.0.x.

mykaul commented 11 months ago

With the current plan it will miss 1.0.0. If it's important enough (why? can you please give a background?), we can reconsider the plan or have it as part of 1.0.x.

Cost, but more importantly, it confuses customers when they see those connections.

wprzytula commented 7 months ago

IIUC, such heuristics (suggested by @piodul above) would be satisfactory:

WDYT? @Lorak-mmk @avelanarius @mykaul

wprzytula commented 7 months ago

After discussion with @Lorak-mmk, the conclusion is that the above heuristics is a reasonable default, but we have to provide a way to override the DC preferred for control connections with a user-provided one. For that, a SessionConfig's parameter should be added.

wprzytula commented 7 months ago

Yet another observation: The notion of "the local DC" and "the local rack" are constant for the driver instance; i.e., we could enable the user to set it only once, upon Session construction. Then, there would be configurable options for:

This way the user won't have to provide the preferred DC and rack separately for control connections and for LBP.