feat: Consistent hashing with bounded loads algorithm for sharding (#16564)

* Adds consistent hashing with bound loads sharding algorithm

Signed-off-by: Akram Ben Aissi <akram.benaissi@gmail.com>

* Make the assignement consistent accross all clusters
- The assignment or running of the algorithm has to be consistent across all the clusters. Changed the function to return a map where the consistent hash will be used to build the map

- Modifications to the createConsistentHashsingWithBoundLoads function. This will create the map for cluster to shard. Note that the list must be consistent across all shards so that is why the cluster list must be sorted before going through the consistent hash algorithm

Signed-off-by: Akram Ben Aissi <akram.benaissi@gmail.com>

* Extracting constant and simplifying boolean expression

Signed-off-by: Akram Ben Aissi <akram.benaissi@gmail.com>

* Update docs: consistent-hashing sharding algorithm

Signed-off-by: Akram Ben Aissi <akram.benaissi@gmail.com>

---------

Signed-off-by: Akram Ben Aissi <akram.benaissi@gmail.com>
This commit is contained in:
Akram Ben Aissi
2024-06-05 19:28:19 +01:00
committed by GitHub
parent ea909fe820
commit 75cd97d6d4
12 changed files with 496 additions and 15 deletions

View File

@@ -117,7 +117,13 @@ const (
RoundRobinShardingAlgorithm = "round-robin"
// AppControllerHeartbeatUpdateRetryCount is the retry count for updating the Shard Mapping to the Shard Mapping ConfigMap used by Application Controller
AppControllerHeartbeatUpdateRetryCount = 3
DefaultShardingAlgorithm = LegacyShardingAlgorithm
// ConsistentHashingWithBoundedLoadsAlgorithm uses an algorithm that tries to use an equal distribution across
// all shards but is optimised to handle sharding and/or cluster addition or removal. In case of sharding or
// cluster changes, this algorithm minimises the changes between shard and clusters assignments.
ConsistentHashingWithBoundedLoadsAlgorithm = "consistent-hashing"
DefaultShardingAlgorithm = LegacyShardingAlgorithm
)
// Dex related constants