Redis: Use Redis replica without cluster mode

Created on 1 Dec 2016  ·  8Comments  ·  Source: go-redis/redis

We have Redis master + replica configuration without using cluster mode. We would like to route reads to both based on latency. I see go-redis has this feature but it seems it's only available with cluster mode. Any plans to support it on non cluster client?

Most helpful comment

I'm having the same need, would love to see this feature of using read-replica without sentinel/cluster.

All 8 comments

No, I am not aware of any way to achieve this. And since this is essentially a Redis Cluster with 2 nodes (master+slave) I don't see much value in supporting this in standard client...

It's quite common for people to have Redis read-replicas without Redis being in cluster-mode, at least for now since it guarantees strong consistency and is operationally simpler.

Another issue, https://github.com/go-redis/redis/issues/673, is also asking for this feature.

If you don't need master sharding and you just want to scale out reads than this non-cluster mode setup of read-replicas without cluster-mode is more performant. Since the demand for this feature is present and it has been implemented by https://github.com/luin/ioredis I am bumping this.

This difficulty I see here is how to iterate over read-replicas.

It would be great if you allow to choose different routing strategies. For our use case we want routing by latency (which you already have in cluster client) while others might want round robin routing.

By the way, glad you saw the need for this feature. Thanks!

I'm having the same need, would love to see this feature of using read-replica without sentinel/cluster.

@Kuqd I have the same problem. I solve now having two connections. redisClient and redisClientRead

We also have a similar workaround. Since we have multiple read replicas we initialise multiple go-redis clients, put them in a slice and then randomly pick one for read operations.

@pranas @ramonberrutti This is good workaround. Thanks.

Though for my use case it requires a bit of refactor since I'm reading and writing a lot. I'll think about it thanks.

See https://godoc.org/github.com/go-redis/redis#example-NewClusterClient--ManualSetup. It uses 2 master nodes, but using single master should work too.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Turing-Chu picture Turing-Chu  ·  3Comments

MaerF0x0 picture MaerF0x0  ·  7Comments

mikhailsizov picture mikhailsizov  ·  5Comments

mouhong picture mouhong  ·  3Comments

expectrox picture expectrox  ·  4Comments