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

replica behavior #186

Open
travisghansen opened this issue Feb 4, 2025 · 5 comments
Open

replica behavior #186

travisghansen opened this issue Feb 4, 2025 · 5 comments

Comments

@travisghansen
Copy link

With this configuration what should the behavior be?

apiVersion: hyperspike.io/v1
kind: Valkey
  name: valkey
spec:
  nodes: 1
  replicas: 2

I have 3 pods (0-2), all of them show role:master and I don't see any replication happening among members.

@dmolik
Copy link
Member

dmolik commented Feb 4, 2025

So there is some history here, but suffice to say, this is a bug that I was going to fix with or soon after I implemented zero downtime upgrades, can you hang tight for a few days?

@travisghansen
Copy link
Author

Of course! Just wasn't sure what to expect. Been a while since I dug into the depths of redis semantics.

Assuming replication is working as desired, how does the Service ensure writes are sent to the master? Or does the protocol have all the brains to understand that and make sure that after initial connection reads/writes go where they are supposed to?

@dmolik
Copy link
Member

dmolik commented Feb 4, 2025

okay so, I'm happy to get on a video call and explain this, but it all starts with the concept of SLOTS, which is like a logical partition a Redis now Valkey Cluster gets about 16 and a half thousand slots, a Master Node is the primary owner of some number of slots, additionally all slots must be 'owned' by some combination of masters. All that said a slave node is a read only replica of a master node. In the CRD, nodes are master nodes and replicas are slaves of a master, so in theory you should have nodes x replicas pods. Funny note, in theory you could have 16k master nodes.

When you connect to a Valkey cluster, the node will check if the slot is 'owned' locally and will serve the value, if not the client gets a redirect message, and will then connect to the node with the next slot, in Valkey Clusters with many slave nodes there is a concept of read-only operations being redirected to slave nodes.

I'm no expert when it comes to Valkey networking topology so my suggestion is to checkout the docs: https://valkey.io/docs/ or ask a question in the discussions: https://github.com/orgs/valkey-io/discussions

@travisghansen
Copy link
Author

travisghansen commented Feb 5, 2025

OK that sounds sane. Thanks for the refresher.

I have 1 small change I would make to the above statement: number of pods will be (<nodes> + (<nodes> * <replicas>)) vs nodes x replicas.

Thanks!

@dmolik
Copy link
Member

dmolik commented Feb 5, 2025

Correct, thank you.

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

No branches or pull requests

2 participants