go-redis icon indicating copy to clipboard operation
go-redis copied to clipboard

add/remove shards in redis ring

Open szuecs opened this issue 2 years ago • 2 comments

We use redis ring client to shard access to redis for our rate limit infrastructure in Kubernetes https://opensource.zalando.com/skipper/tutorials/ratelimit/#redis-based-cluster-ratelimits. I would like to add and remove shards on demand while Kubernetes is scaling-out redis instances. I tried to implement it by closing and recreating the redis ring, but I think it would be better (less locks required) to trigger it via a library call.

One idea I had was to have a func() []string that is called every configurable time.Duration with a time.Ticker to set the Members and propagate these into the library ringShards. Or we could also do the triggering ourselves and the library just provides ReconfigureShards(shards []string). Do you have a better idea how to make this happen?

I am willing to create a PR if it makes sense for you.

szuecs avatar Apr 26 '22 14:04 szuecs

@szuecs I think that providing API like ring.SetAddrs(addrs map[string]string) is a better way forward and I would gladly review such a PR :+1:

vmihailenco avatar May 21 '22 13:05 vmihailenco

@vmihailenco can you check the updated PR? Thanks!

szuecs avatar Aug 01 '22 20:08 szuecs

I think we can close this one

szuecs avatar Oct 06 '22 13:10 szuecs