Replies: 2 comments 4 replies
-
Hi @proost, Thank you for your proposal. It looks good generally, however, there are several things unclear:
BTW, in my opinion, client-side caching should be a better choice for read-heavy applications. Have you tried that? |
Beta Was this translation helpful? Give feedback.
4 replies
-
close: #402 |
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 Read-Write Splitting feature to cluster client to use Redis cluster more efficiently.
Problem Definition
Background
Someone who wants to use redis cluster more efficiently with rueidis, have to use two rueidis clients, that one is for primary and the other is replicas. Because rueidis doesn’t support Read-Write splitting.
Goal
Non-Goal
Plan
Read-Write Splitting configuration is defined in
ReadFrom
struct. In this proposal, I defined onlyReplicas
option which client use replicas for read operations.ReadFrom
option is defined asClientOption
field so that user can configure Read-Write Splitting configuration.ReadFrom
can’t work withReplicaOnly
option. because a client can send a command to primary node. so constructor should return error whenReadFrom
is set &ReplicaOnly
is true.Cluster client should have read connection & write connection per slot. If a read command is given, use read connection to send command to a slot. If a write command is given, use write connection to send command to a slot.
readConnsPerSlot
&writeConnsPerSlot
are refreshed in a_refresh
function.Do
,DoMulti
,DoCache
,DoMultiCache
,Receive
have to pick connection to send commands. AllCompleted
type commands hasIsReadOnly
method. UsingIsReadOnly
method,pick
can know whether command is read operation or not. sopick
method changed like this.if
ReadFrom
is set, then choose read connection or write connection inpick
method.Pipelining method, like
DoMulti
, chooses each connection per command in_pickMulti
method or_pickMultiCache
Currently
Cacheable
type doesn’t supportIsReadOnly
method. So defineIsReadOnly
method too.Beta Was this translation helpful? Give feedback.
All reactions