Skip to content
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

Prioritize replica node #1067

Closed
vladimir-stornest opened this issue Feb 7, 2022 · 2 comments · Fixed by #1150
Closed

Prioritize replica node #1067

vladimir-stornest opened this issue Feb 7, 2022 · 2 comments · Fixed by #1150

Comments

@vladimir-stornest
Copy link

vladimir-stornest commented Feb 7, 2022

When there are multiple replica nodes per master (in a cluster mode), is there an option to prioritize which replica node to be used?

Let's say I have three master nodes: A, B, C. Each master node has two replicas: A1, A2, B1, B2, C1, C2.

The replica: true option is used. When a key needs to be read from the A slot, which node will be used between A1 and A2? Is there an option where I can prioritize the A1 node? I'm asking because A1 would be nearest to the application, so reading from it would have the lowest latency.

@supercaracal
Copy link
Contributor

There is no way to do so in the current implementation for cluster mode.

@map[slot][:slaves].sample

It seems that there is a similar issue for sentinel mode.

There might be indeed a performance issue by balancing across regions or availability zones. The more number of queries is, the more total latency is. But I'd say that it might be a bit over responsibility if the client care about it. The client just fetch server connection information.

It seems that Redis cluster v2 will be able to proxy requests and aware placement of servers.

Request proxying:
The idea here is that Redis server nodes could proxy incoming requests to the desired node instead of relying on heavy client side logic to know the cluster topology. Simplifies some of the work for workloads that don’t want to maintain a heavy client. This would be an optional configuration.

Placement awareness:
Today the individual nodes have no concept of how they are placed compared to each other, and will happily allow all the primaries to exist in the same zone. This also may include the notion of multi-region awareness.

@supercaracal
Copy link
Contributor

supercaracal commented Sep 8, 2022

@vladimir-stornest I added :replica_affinity option. If you would like, you can use.

https://github.com/redis/redis-rb/tree/master/cluster

Redis::Cluster.new(nodes: nodes, replica: true, replica_affinity: :latency)

FYI:

  • The redis gem was decoupled to redis and redis-clustering gems.
  • The redis gem now depends on the redis-client gem.
  • The redis-clustering gem now depends on the redis-cluster-client gem.
  • https://github.com/redis-rb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants