0

The standard and premium pricing tiers of Azure Redis Cache provide master/slave replication:

Standard—A replicated cache in a two-node primary/secondary configuration managed by Microsoft, with a high-availability SLA.

But the Azure portal provides connection details (hostname, port, key) for only a single redis instance. Is there a way to connect to connect to the slave process in a replica?

Malt
  • 28,965
  • 9
  • 65
  • 105

2 Answers2

2

Since the Azure Redis service manages replication and automatic failover on your behalf, it is useful not to make any assumptions about which node is Master as that could change on a failover. Hence the service exposes only one endpoint and ensures that any requests to that endpoint hit the correct Master. It is technically possible to connect to Master or Slave, but Azure doesn't expose it and it requires checks on the client side to ensure that the node is indeed Master or Slave.

If you turn on clustering, the Redis cluster protocol is used. Under this protocol, you can run a cluster nodes command and it should return get a list of Master and slave nodes and the ports that each of these are listening on.

Carl Dacosta
  • 873
  • 4
  • 13
  • Thanks, Carl. So under Basic/Standard tiers, I should use simple a single instance configuration for the client? – Malt Oct 29 '17 at 09:26
  • Also, could you clarify your point about "requires checks on the client side to ensure that the node is indeed Master or Slave"? What checks are expected of the client? What clients support them? – Malt Oct 29 '17 at 09:31
  • For Basic / Standard / Premium (Clustered or non-clustered), simply connect to .redis.cache.windows.net on port 6380 (SSL) or 6379 (Non-SSL). In non-clustered mode, ports 6380 or 6379 will directly cause the connection to happen to the Master node, so there is no need to worry about that aspect. In clustered mode, Redis clients will automatically query fro cluster configuration (cluster nodes) and then use the config accordingly. So, again, there is no need to worry about which node you are connecting to. – Carl Dacosta Oct 29 '17 at 19:38
  • In clustered mode, if you connect to Master or slave directly, you can always run the "info replication" command to know whether you are connected to Master or Slave. Again, it is advisable to just connect to port 6380 or 6379 and let the clients deal with the configuration. – Carl Dacosta Oct 29 '17 at 19:40
  • Thing is, I'm not sure that the clients know how to "deal with the configuration". I've been trying to work with the lead developer of [redisson](https://github.com/redisson/redisson) on this for the past few days. He says that redisson detects a failover only when the IP address of the instance changes. Can you point me to some documentation about the correct way in which clients are meant to deal with a failover to a replica? – Malt Nov 02 '17 at 09:07
  • 1
    Malt, the thing is that your client doesn't need to deal with a failover to the replica. Your client just assumes you are talking to the Master. The service ensures that you are always talking to the Master when you communicate with your cache over .redis.cache.windows.net on port 6379 or 6380. – Carl Dacosta Nov 03 '17 at 15:49
1

The Redis service manages replication and failover, for high availability. This is not something exposed to you. That is, you cannot connect directly to the slave/secondary.

David Makogon
  • 69,407
  • 21
  • 141
  • 189
  • I see. So as far as Redis client libraries are concerned, they're working against a single server? For instance, reddisson has a "replicated mode" in which you specify all redis nodes. – Malt Oct 26 '17 at 11:39
  • Yes, that's true. The ports 6379 (non-ssl) or 6380 (ssl) will redirect accordingly so that your connection lands on the right node. You don't have to specify all the nodes. – Carl Dacosta Oct 29 '17 at 19:42