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

Problem with get slave via sentinel. #673

Closed
valentyn-hrynevich opened this issue Dec 1, 2017 · 9 comments
Closed

Problem with get slave via sentinel. #673

valentyn-hrynevich opened this issue Dec 1, 2017 · 9 comments

Comments

@valentyn-hrynevich
Copy link

How to get a slave instance via sentinel.
For example https://github.com/andymccurdy/redis-py have method "slave_for" that return client object with slave host.
How to get something same using this library.
I don't found anything about in a documentation.
Thanks for help.

@vmihailenco
Copy link
Collaborator

NewFailoverClient returns plain redis *Client so I am not sure where to add slave_for method. And now we even don't retrieve/store information about slaves which is another problem.

I guess that you want to use slave(s) for read only commands. If that is the case I would recommend you to use Redis Cluster and enable ClusterOptions.ReadOnly and/or ClusterOptions.RouteByLatency.

@valentyn-hrynevich
Copy link
Author

valentyn-hrynevich commented Dec 12, 2017

Okay, but I don't want to configure cluster stack. May be will be good to implement parameter for get random slave instead of getting master permanently.
What do you think about it?
E.x https://github.com/luin/ioredis has parameter role.

@totoyotonet
Copy link

I do not know how to do it

@vmihailenco
Copy link
Collaborator

Closing since I don't understand what you are trying to achieve and there is no good place for method like "slave_for".

@agparadiso
Copy link

Im trying to do the same it was asked here, get a sentinel slave in order to split reads/writes. haven't found a way of doing it with this library. btw the closing reason doesn't seems to be appropriated.

@vmihailenco
Copy link
Collaborator

#997 looks promising, but it requires more work.

@eafzali
Copy link
Contributor

eafzali commented May 10, 2019

@vmihailenco I'm happy to work on that if you give it a review and could help me understand your build pipeline

@yushizhao
Copy link

yushizhao commented Jun 10, 2019

I have the same need, namely, route all read commands to slaves.
From what I read here, I think @vmihailenco have suggested to create a go-redis ClusterClient with ClusterOptions.ReadOnly. Were you suggesting then all the read commands passed by ClusterClient::Do will route to a slave while all the write commands go to master? I see there is a work around in clusterState. However, I want to confirm when Sentinel failover a master, how would clusterState get updated? Thank you.

@landrade
Copy link

landrade commented Nov 21, 2019

Any workaround to resolve it? Write on master and read from slaves is a common approach for applications that don't need sharding data but have a high throughput. It will be good if we have a alternative to do it.

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

No branches or pull requests

7 participants