Replies: 2 comments 3 replies
-
I think this generally looks very good, especially the combination of the ShardsRefreshInterval, and can be implemented easily. But instead of hiding the selector, I prefer exposing the following API to users: type ReplicaInfo struct {
Addr string
// Zone string <- we could need this field in the future, see https://github.com/valkey-io/valkey-glide/pull/2539
}
SlotReplicaSelector: func(slot uint16, replicas []ReplicaInfo) int
|
Beta Was this translation helpful? Give feedback.
3 replies
-
Close: #692 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
Adding to read only command preference option to rueidis. read only command preference can distributes read only commands to primary and replicas evenly.
Problem Definition
Background
Handling read only command via replica makes valkey/redis cluster scalable. When using replica, it is important to distribute loads in a each node. Because uneven load balancing makes cluster less-scalable and inefficient in terms of resource usage especially read-heavy workload.
Current rueidis can distribute command using “SendToReplicas”. But problem is “SendToReplicas” doesn’t consider how many nodes in a each shard. If a valkey/redis cluster uses auto scaling, “SendToReplicas” shows less efficient load balancing.
Goals
Keywords Description
Design
Load Balancing Strategy
Reader node selection.
One of important thing in load balancing is
readerNodeSelector
.readerNodeSelector
chooses which node is reader each slot.readerNodeSelector
runs in_refresh
function, when settingconn
per each slot.User can configure
readerNodeSelector
viaReadPreference
option inClientOption
.Using factory method,
readerNodeSelector
implementation is returned internally.Routing to reader node.
If
ReadPreference
is configured inClientOption
, thensendToReader
should be set toSendReplicas
function.sendToReader
sends read only command to selected reader node.Dynamic Load Balancing
We can achieve
Any
read preference andShardsRefreshInterval
.If
Any
is set, thennewReaderNodeSelector
returnsanyNodeSelector
.anyNodeSelector
chooses connection randomly. So If replica is added because of auto scaling, then after refreshed cluster connection cache, we can distribute read requests to each node evenly.Alternatives Considered
I’ve considered making custom
SendReplicas
. But it is hard. Because In aSendReplicas
we can’t know how many nodes in each shard.Beta Was this translation helpful? Give feedback.
All reactions