Skip to content

Commit 04641be

Browse files
committed
improve readability
Signed-off-by: Ben Ye <[email protected]>
1 parent aba4b6a commit 04641be

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

docs/blocks-storage/store-gateway.template

+7
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,20 @@ The store-gateway supports two sharding strategies:
5454

5555
- `default`
5656
- `shuffle-sharding`
57+
- `zone-stable-shuffle-sharding`
5758

5859
The **`default`** sharding strategy spreads the blocks of each tenant across all store-gateway instances. It's the easiest form of sharding supported, but doesn't provide any workload isolation between different tenants.
5960

6061
The **`shuffle-sharding`** strategy spreads the blocks of a tenant across a subset of store-gateway instances. This way, the number of store-gateway instances loading blocks of a single tenant is limited and the blast radius of any issue that could be introduced by the tenant's workload is limited to its shard instances.
6162

6263
The shuffle sharding strategy can be enabled via `-store-gateway.sharding-strategy=shuffle-sharding` and requires the `-store-gateway.tenant-shard-size` flag (or their respective YAML config options) to be set to the default shard size, which is the default number of store-gateway instances each tenant should be sharded to. The shard size can then be overridden on a per-tenant basis setting the `store_gateway_tenant_shard_size` in the limits overrides.
6364

65+
The **`zone-stable-shuffle-sharding`** strategy achieves the same as the **`shuffle-sharding`** strategy, but using a different sharding algorithm. The new sharding algorithm ensures that when zone awareness is enabled, when shard size increases or decreases by one, the replicas for any block should only change at most by one instance. This is important for querying store gateway because a block can be retried at most 3 times.
66+
67+
Zone stable shuffle sharding can be enabled via `-store-gateway.sharding-ring.zone-stable-shuffle-sharding` CLI flag.
68+
69+
It will become the default shuffle sharding strategy for store gateway in `v1.17.0` release and the previous shuffle sharding algorithm will be removed in `v1.18.0` release.
70+
6471
_Please check out the [shuffle sharding documentation](../guides/shuffle-sharding.md) for more information about how it works._
6572

6673
### Auto-forget

docs/configuration/v1-guarantees.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,5 +106,5 @@ Currently experimental features are:
106106
- `-ingester.out-of-order-time-window` (duration) CLI flag
107107
- `out_of_order_time_window` (duration) field in runtime config file
108108
- Store Gateway Zone Stable Shuffle Sharding
109-
- `-zone-stable-shuffle-sharding` CLI flag
109+
- `-store-gateway.sharding-ring.zone-stable-shuffle-sharding` CLI flag
110110
- `zone_stable_shuffle_sharding` (boolean) field in config file

pkg/ring/ring.go

+6-10
Original file line numberDiff line numberDiff line change
@@ -727,9 +727,6 @@ func (r *Ring) shuffleShard(identifier string, size int, lookbackPeriod time.Dur
727727
if zoneStableSharding {
728728
numInstancesPerZone = size / len(r.ringZones)
729729
zonesWithExtraInstance = size % len(r.ringZones)
730-
if zonesWithExtraInstance > 0 {
731-
numInstancesPerZone++
732-
}
733730
} else {
734731
numInstancesPerZone = shardUtil.ShuffleShardExpectedInstancesPerZone(size, len(r.ringZones))
735732
}
@@ -762,7 +759,12 @@ func (r *Ring) shuffleShard(identifier string, size int, lookbackPeriod time.Dur
762759
// To select one more instance while guaranteeing the "consistency" property,
763760
// we do pick a random value from the generator and resolve uniqueness collisions
764761
// (if any) continuing walking the ring.
765-
for i := 0; i < numInstancesPerZone; i++ {
762+
finalInstancesPerZone := numInstancesPerZone
763+
if zonesWithExtraInstance > 0 {
764+
zonesWithExtraInstance--
765+
finalInstancesPerZone++
766+
}
767+
for i := 0; i < finalInstancesPerZone; i++ {
766768
start := searchToken(tokens, random.Uint32())
767769
iterations := 0
768770
found := false
@@ -805,12 +807,6 @@ func (r *Ring) shuffleShard(identifier string, size int, lookbackPeriod time.Dur
805807
break
806808
}
807809
}
808-
if zoneStableSharding && zonesWithExtraInstance > 0 {
809-
zonesWithExtraInstance--
810-
if zonesWithExtraInstance == 0 {
811-
numInstancesPerZone--
812-
}
813-
}
814810
}
815811

816812
// Build a read-only ring for the shard.

0 commit comments

Comments
 (0)