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
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
-
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.readerNodeSelectorchooses which node is reader each slot.readerNodeSelectorruns in_refreshfunction, when settingconnper each slot.User can configure
readerNodeSelectorviaReadPreferenceoption inClientOption.Using factory method,
readerNodeSelectorimplementation is returned internally.Routing to reader node.
If
ReadPreferenceis configured inClientOption, thensendToReadershould be set toSendReplicasfunction.sendToReadersends read only command to selected reader node.Dynamic Load Balancing
We can achieve
Anyread preference andShardsRefreshInterval.If
Anyis set, thennewReaderNodeSelectorreturnsanyNodeSelector.anyNodeSelectorchooses 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 aSendReplicaswe can’t know how many nodes in each shard.Beta Was this translation helpful? Give feedback.
All reactions