-
-
Notifications
You must be signed in to change notification settings - Fork 184
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
Implement redis redirects (cluster), switch to enable/disable MGET
#147
Conversation
multi get in a cluster with read replicas only works when the keys to be retrieved are allocated in the same hash slot https://redis.io/topics/cluster-spec#keys-hash-tags
When I have time I may take a look at how to solve this with using hash tags in Avoiding |
separate option to turn off `multiGet` even when no read replicas are configured
Turns out, this still doesn't solve the issues we have with yii2-redis and AWS ElasticCache. Mainly they are:
I thought adding read replicas to the config would prevent redirects. Then I just would have to avoid I'm currently trying to implement the |
MGET
Anything else I should be doing before you can pull this change? The only thing I can think of right now, is that there should be an implementation of setting multiple keys in the same hash slot. Then the If there's time, I will take a look at it. But right now, this change works well for us (we're using it on AWS EB with ElasticCache Redis cluster mode enabled). |
if (isset($responseParts[2])) { | ||
$this->close(); | ||
$this->redirectHostname = $responseParts[2]; | ||
$this->open(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's a good idea to open and close the connection each time a redirect occurs. It would be better to have a pool of connections to choose from and call the method on the correct connection object for the other host.
We have a cluster implementation in Yii core for SQL DB Connection. Maybe it is possible to make a generic multi-connection implementation that works for both SQL clusters and redis clusters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good point. Will take a look at it when I have time.
Meanwhile we discovered that even
Which I will fix first, before looking at the connection pool. |
version 2.0.9
multi get in a cluster with read replicas only works when the keys to be
retrieved are allocated in the same hash slot
https://redis.io/topics/cluster-spec#keys-hash-tags