Scaling
This guide covers changing the size of a Valkey cluster you own: adding or removing shards, and adding or removing replicas. It also covers what to expect while the Momento Valkey Operator carries out the change.
Scaling shards
Edit spec.shards to change the number of shards:
kubectl -n my-app patch valkeycluster my-cluster --type merge -p '{"spec": {"shards": 4}}'
Scaling out or in changes how the cluster's 16384 hash slots are distributed, not just how many nodes exist. The operator moves slots between shards with a single server-side command that starts an asynchronous slot migration. The migration proceeds one batch of slots per reconciliation tick, until every shard holds an even share.
- Scaling out adds new, empty shards and migrates slots from existing shards onto them until the distribution is even again.
- Scaling in fully drains the smallest shard (migrating all of its slots to other shards) before removing it. Only the drained shard's primary and replicas are removed; nothing else in the cluster is touched.
Slot migration relies on a Valkey 9+ command. Clusters running an older Valkey image cannot reshard. See Compatibility for version requirements.
Scaling replicas
Edit spec.replicasPerShard to change replica count uniformly across every shard:
kubectl -n my-app patch valkeycluster my-cluster --type merge -p '{"spec": {"replicasPerShard": 2}}'
The operator adds or removes replicas evenly, one node at a time, until every shard reaches the target count. This doesn't move any hash slots; only the number of copies of each shard's data changes.