Skip to content
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

FailoverClient with read-only support #1199

Merged
merged 3 commits into from
Sep 4, 2020

Conversation

nextsux
Copy link
Contributor

@nextsux nextsux commented Nov 26, 2019

Allow FailoverClient ReadOnly option. Client then connects to redis replicas (or master if no slave is available) for performing read-only queries. User is responsible for deciding which query can be run against it.

It aims to implement the same as #997 but without misusing ClusterClient which is not suitable for this.

@dstrop
Copy link

dstrop commented Nov 29, 2019

sentinel slaves returns all slaves sentinel knows about even disconected slaves (they will have flags s_down and disconnected)
this might cause dial to try connecting to dead slave and fail

@nextsux
Copy link
Contributor Author

nextsux commented Nov 29, 2019

Good point @dstrop I'll fix that

@landrade
Copy link

Hi people, is there something that I can do to help you with it? I'm so interested in this feature.

@takakawa
Copy link

I want this feature too! When will the commit be merged?

@DrWrong
Copy link

DrWrong commented May 21, 2020

should we listen the sentinel's o_down event to remove the redis conn in Pool

@fatpat
Copy link

fatpat commented Jul 15, 2020

is there any chances for this PR to come up in v8 somehow ?

@dmitsh
Copy link
Contributor

dmitsh commented Sep 1, 2020

there is a conflicting file

@nextsux nextsux force-pushed the sentinel-read-only branch 2 times, most recently from 7b93c9c to 75cfccc Compare September 3, 2020 21:12
@dmitsh
Copy link
Contributor

dmitsh commented Sep 4, 2020

@vmihailenco , could you review this PR?

@vmihailenco
Copy link
Collaborator

@nextsux sorry for ignoring this.

The code looks clean and self-contained so I don't mind merging it. But I guess it will not "properly" balance the load for 2 reasons:

  • This PR really balances connections in the pool, not Redis commands.
  • What is worse - go-redis does not evenly utilizes connections in the pool. It uses First In, First Out queue - some connections are used more often than others.

But that is all theory and in practise this PR may be good enough for some workloads. @nextsux do you have any experience using this PR under the load?

First In, First Out queue was picked so some connections are unused at all and we can close them after some time. I think it is not terribly useful and we can change pool to use other strategy if it helps with this PR.


But really using ClusterClient (PR #997) looks more appealing to me. It already has all the logic to properly balance the load - all we need is some flag / refactoring to disable cluster specific features...

@nextsux
Copy link
Contributor Author

nextsux commented Sep 4, 2020

no problem @vmihailenco.
You're right it balances connections, not commands which works pretty fine for me. I'm running earlier version of this patch (before rebase yesterday, https://github.com/nextsux/redis/tree/sentinel-read-only-v7) in production since I've created this PR - that is from 2020/11 and works fine:

image

red one is current master which is not receiving read traffic.

@vmihailenco
Copy link
Collaborator

Good, let's hope it will work even better for others too. Meging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants