Sharding in Yandex Managed Service for Valkey™
Sharding in Yandex Managed Service for Valkey™ works based on Valkey™ Cluster
Advantages of sharding
Sharding allows you to distribute loads across database hosts, which helps bypass the resource restrictions of a single server. This is particularly important when you handle large amounts of data or run compute-intensive jobs.
Horizontal scaling involves distributing datasets and load across multiple nodes. A single machine may underperform in terms of capacity or speed; however, in a horizontally-scaled cluster, each machine processes only a portion of total workload and stores only a portion of total data. This helps make your system more efficient compared to a single high-capacity server.
You can read more about Valkey™ database sharding in the Valkey™ documentation
Valkey™ Cluster structure
Valkey™ Cluster allows you to create a Valkey™ installation with automatic data sharding between the hosts. Valkey™ Cluster comprises multiple hosts for storing your data. Valkey™ Cluster is divided into shards, each consisting of a master and a set of replicas. Data from clients is written to the master hosts and then replicated.
Each cluster has 16,348 hash slots evenly distributed across the shards. Slots define the dataset stored in the shard.
Scalability
If you need to scale your cluster horizontally, you can add new shards to it.
New shards are created without hash slots. To redistribute data, you must rebalance your cluster. Afterwards, some of the existing slots will move to the new shard.
You do not need to stop the cluster to move slots between shards. If the client queries the master for data that was moved to another shard, the query is forwarded to the new shard where the data was moved to. Hosts do not proxy queries; instead, they forward the client to the proper shard.
Yandex Managed Service for Valkey™ can contain between 1 and 10 shards, each comprising a different number of hosts. The minimum number of hosts per shard depends on the selected disk type.
You can create a cluster with either a single shard or three or more shards. You cannot create a cluster with two shards, but you can change the number of shards in an existing cluster.
For more information about limits on the number of hosts per shard, see Quotas and limits.