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

readOnlyForReplica flag question #3929

Closed
ruispereira opened this issue Aug 21, 2024 · 7 comments · Fixed by #3932
Closed

readOnlyForReplica flag question #3929

ruispereira opened this issue Aug 21, 2024 · 7 comments · Fixed by #3932
Milestone

Comments

@ruispereira
Copy link

Checking master branch, in the class https://github.com/redis/jedis/blob/master/src/main/java/redis/clients/jedis/DefaultJedisClientConfig.java there's a new flag to allow reading from replica nodes. This can be used with sentinels? Or in a master-slave configuration?

Another question is when a new release will be shipped with this feature?

@sazzad16
Copy link
Collaborator

It is meant for READONLY command which is dedicated for Redis Cluster.

Thank you for asking this. I guess we'd have to rename+document it further.

@sazzad16 sazzad16 added this to the 5.2.0 milestone Aug 21, 2024
@ruispereira
Copy link
Author

ruispereira commented Aug 22, 2024

Thank you for your quick answer!
So, my team is using redis sentinels, for high availability, and using Spring Redis OM, we are reaching always master node for read and writes and we are getting 100% CPU most of the time for master node.
Is there any way to force reads to go to replica nodes instead of reaching always master node?
Thanks in advance.

@sazzad16
Copy link
Collaborator

sazzad16 commented Aug 22, 2024

@ruispereira Not readily.

You may extend SentineledConnectionProvider and override getConnection(CommandArguments) method to achieve that.

@ruispereira
Copy link
Author

Thank you!
And is there any way to known if the current operation is a read or write operation?

@sazzad16
Copy link
Collaborator

Using CommandArguments.getCommand() you would have recognize.
In your case it's enough to recognize only your HOT READ commands.

@ruispereira
Copy link
Author

Ok, understand!
One more question, how can i get the replicas? I see that jedis class have a sentinelReplicas method to get the list of replicas, i need to use this right? Do i have to have a thread, like the sentinel have, to known if a given replica die or something, so we will always have the list of replicas fresh..

@sazzad16
Copy link
Collaborator

It's up to you.

Your suggestion is of course a solution.

Someone else may consider maintaining list on their own and/or communicating with the replicas by executing a command (i.e. ping).

In either of the ways, separate thread could be needed.

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

Successfully merging a pull request may close this issue.

2 participants