-
Notifications
You must be signed in to change notification settings - Fork 997
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RedisClusterClient default connection congestion #252
Comments
Thanks for the ticket. The default connection is created to the first node able to connect. There are two other options which both seem reasonable to me:
|
The default will be to connect to the node with the least clients. For now
|
lettuce now exposes getSocketAddressSupplier to control the order of connection points when attempting to connect the default connection. The order can be influenced by subclassing RedisClusterClient and overriding getSocketAddressSupplier. TopologyComparators provides a predefinedSort that allows sorting the connection points by the order of a list of RedisURI (e.g. the initial seed nodes). These changes give flexibility to implement custom ordering.
Switch the connection point ordering to client count ordering instead of latency ordering. This change reduces connection congestion of the default cluster connection by using the nodes with the lowest client counts. The view of client counts is cached and is refreshed upon topology refresh.
Implemented. |
Following up from my question in the Google Group.
As mentioned in the documentation, connections created with
RedisClusterClient
will always create a default connection to the node with the lowest latency. However, this may cause congestion when one node has a lower latency. If all clients experience the lowest latency with a particular node, then all clients will pick that node for its default connection.In my case I'd be happy to use randomly selected nodes. That gives me a more predictable distribution of connections. Perhaps some environments prefer selecting by latency, but maybe lettuce could expose the choice as a client configuration?
The text was updated successfully, but these errors were encountered: