-
-
Notifications
You must be signed in to change notification settings - Fork 35
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
Handle redis cluster via redis load balancer URL #13
Comments
Hello Rui, I'm not familiar with Azure's redis cluster support, but reading this page: https://docs.microsoft.com/en-us/azure/redis-cache/cache-how-to-premium-clustering , it looks like it should work. They do mention using a redis client with cluster support, so that means it should expose the necessary commands to query a cluster. I'm a bit concerned by the If you do try it out, I'd be very interested in hearing about your experience, what worked, what didn't and how I could update the package to better support azure! Thanks, |
Thanks Martin @mna I have tried and it seems working. although connect to individual shard is not officially support, but I can check the redis node's IP via so in cluster setup, I use all internal nodes' address in " Also Dose this redisc follow Thanks |
Hello, You can put either masters or replicas in If so, I believe that would defeat the goal of using redisc. The dial function should always try to connect to the address provided, that's the one the client identified as the right address to connect to the required node. Regarding your last question, to follow Hope this helps! |
Hi Martin @mna regarding "The dial function should always try to connect to the address provided", you mean it will automatically fetch {IP:port} from I define a CreatePool func which will be put like
but I indeed find can not pass the into Thanks |
Ok, thanks for the details, the |
@mna ,in my case, The Thanks |
@mna , let me refine my question in this way. what is the difference between Thanks |
Okay so here's how the redis cluster works. The startup nodes are used to build the topology of the cluster, figure out the masters and replicas. This may change during the execution of your app - e.g. maybe a node will go down, another one will replace it, etc. So that's why those are called "startup" nodes, those are the nodes to use when the app (server, typically) starts, but after that it may change. The client stays up-to-date with those changes. Another thing that the client does is keeping track of which node in the cluster serves which key hash. There are 16384 hash values, and each hash value has a corresponding node. When you get a connection from the cluster and you execute a command, the client will identify which node should be contacted to execute this command based on the key passed to the command (e.g. Now, about the In a stable cluster - typically, the huge majority of the time - the client will always select the right node to contact, so you won't receive In other words (in code), you should do this:
Hope that makes it clearer! |
Thanks @mna for your detailed information. follow up on " it is important that the Dial function of this pool really returns connection to that specific node, not the generic load balancer URL". for cluster case, I will have bunch of different Right now, in Azure redis, In but according to your suggestion, this sounds to be a Hack. not recommended. But I can not find another way, since Azure want to hide all cluster information and only expose one external URL to outside, and let redis client to manage all cluster/pool itself. Can you provide a sample code what is your recommend way to implement the cluster init stage? Thanks |
Hm I think I see where the confusion comes from, you never call In your code, you simply call
So you never actually call Hope this helps! |
Thanks @mna , If redisc calls the Thanks |
FYI, @mna , I have contacted Azure redis dev team, and their response is like: Most Redis clients that understand clustering do the following:
Another dev points out: Normally, you can just put redis URL as startupNode. But you should be aware that our redis URL is actually a load balancer, rather than a real node. Whether this will cause issues depend on concrete implementation. As I know, there is one issue caused by passing load balancer as startup node in Java Lettuce client. You can refer this. redis/lettuce#712 So right now it seems to me only the hack way works in Azure redis
I am not sure whether this is best what I can do with redisc, or some other piece I should improve. please let me know your comments, that will be great helpful Thanks |
Hello, Yep, that's pretty much what a redis cluster client will do. It's a good recommendation to pass the redis URL as startup node, as it probably ensures that it can connect to a valid node in the cluster, and then redisc will discover the actual addresses of each active node. However, in
So the Martin |
Thanks for reply @mna , but it dose not work in my case, I always get "redisc: failed to get a connection",here is my connection type
and in createPool I use what you reommended
is there any way I can completely get rid of startup nodes or any internal information, just provide the external URL(Load Balancer URL) and make it work? I guess it is because redisc need to have a real redis node as Thanks |
Where is your app running from? Does it have access to the internal nodes (IP address and port, not the entrypoint URL of the load balancer)? E.g. if you try to connect from one of the internal node addresses from the server where the app runs using My guess is that your app doesn't have access to the cluster nodes' addresses from where it runs. |
I am running it in my local machine, but it should have cert and SSL configured, I am able to connect to but when putting Thanks |
Hi @mna some more update on debug: if I only put I tried two different ways:
but both returns " It looks like to me problem is: When redisc first establish SSL connection, it will call but later when it tries to find other nodes in redis cluster to connect, and when Is there any solution to this? Thanks |
Update again, if I disable the Azure redis cache SSL and expose none SSL port, only use PWD to Auth, it works!! so looks like my former assumption of SSL auth problem is correct Thanks |
This is handled by redigo (used by redisc to manage connections and pools).
See https://godoc.org/github.com/garyburd/redigo/redis#DialTLSConfig and
https://godoc.org/github.com/garyburd/redigo/redis#DialUseTLS. You should
specify those DialOptions on Cluster.DialOptions.
…On Sat, Apr 14, 2018 at 03:52 Rui Zhang ***@***.***> wrote:
Update again,
if I disable the Azure redis cache SSL and expose none SSL port, only use
Passport to Auth, it works! so looks like my former assumption of SSL auth
problem is correct
Thanks
Rui
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#13 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAqQoE9sRn4nohIiVM-m3PvFWAmJVA8cks5toarHgaJpZM4TQZqn>
.
|
Yes, I am aware of using redigo to do SSL, but the question I have is when we any better way I can force SSL connection to load balancer instead of Thanks |
Ah I see, yeah so you don't need SSL in
|
I think this dose not work also, when redisc dial into some other redis nodes. it still need to go to SSL connection, juts it won't SSL directly to redis node, but load balancer. in your code, it will not establish the SSL at all |
I'm afraid I don't understand what is your issue then. You either need TLS and thus have it configured in the dial options, or you don't and thus you set it on/off in the dial options when needed. I'm not familiar with Azure's redis, but I'd expect the external URL to require TLS config so that the endpoint is not publicly accessible from outside the VPN, but the internal nodes to be accessed from inside the VPN (where your binary should run) without TLS. |
Let me double check again. My question is when dial into some redis cluster node, we still need SSL, but not SSL directly to node, rather it needs to dial to Redis load balancer URL. In your former approach, it will directly dial into redis node without SSL, right? |
Hi @mna I think I got some feedback from Azure redis team, so client can directly connect to redis nodes(not necessarily load Balancer), but in Azure redis, different nodes and load balancer shares same IP, but different ports.(via a NAT way) but in dial, seems we split the ports, so we lost port in SSL creation? anyway, it could be a question for redigo.
Thanks |
I think the problem is that Azure redis uses NAT in cluster mode, so every node has same IP but different ports, somehow redisc can not bind investigating more, but if you have some insight, please share Thanks |
One question, the Thanks |
No, |
I got some feedback again from Azure redis team about the recommendation how the cluster client should work. Quote as:
I am not sure whether redisc did same? If not, how can I use redisc to minic the Azure redis behavior? Thanks |
OK, finally I got the client works in SSL mode. here is configuration in Thanks |
Ok, looks like you don't have a trusted certificate. Glad you got it working, closing as this is a connection configuration issue. |
Hi
I am using Microsoft Azure redis and it dose not provide each cluster node individual IP address, rather it will only provide the redis cluster URL(which is actually a load balancer, not real redis nodes). Can this lib handle this? if so, I should put this redis URL in startupNodes or in dialoption's address?
Thanks
Rui
The text was updated successfully, but these errors were encountered: