Repository navigation
Commit d823d63
authored
Ingester: convert global limits to local using actual ring ownership (#7954)
* ring: add ZonalOwnership to report per-zone write ownership
Add (*Ring).ZonalOwnership(op), which returns the fraction of its zone's
hash space each instance receives for writes made with op. Tokens of
instances that op skips and replaces with the next instance (for example
JOINING/LEAVING with Write, READONLY with either write op) are left out,
so their ranges fall to the next remaining token in the zone, matching
Ring.Get.
The result is cached per operation and invalidated when tokens or
instance states change, including state refreshes of cached
shuffle-shard subrings.
This is a building block for computing per-ingester local limits from
actual ring ownership instead of assuming an evenly balanced ring.
Signed-off-by: Alan Protasio <alanprot@gmail.com>
* ingester: convert global limits using the ingester's ring ownership
Add the experimental -ingester.use-ring-ownership-for-limits flag. With
zone-aware replication, global series and metadata limits are converted
to local limits as global * share, where share is the fraction of the
tenant's hash space (or shuffle shard) this ingester owns within its
zone. The current conversion assumes every ingester owns an equal share,
so on an unevenly balanced ring tenants are throttled on the ingesters
with the largest share well before they reach their global limit.
The ownership is computed from a ring fed by the ingester's own
heartbeats (the Lifecycler already reads the full ring on every CAS), so
no KV store watch or traffic is added. Shares are refreshed every 10s
off the push path. Until the first refresh, for tenants whose shard does
not include this ingester, and without zone awareness, the existing
conversion is used.
The write operation used for ownership follows -distributor.extend-writes
so the shares describe where the distributor actually sends series.
Signed-off-by: Alan Protasio <alanprot@gmail.com>
* ingester: require RF == zones for ownership-based limits
Zonal shares assume each zone holds one copy of every key. Reject
-ingester.use-ring-ownership-for-limits without zone-aware replication,
and fall back to the equal-share conversion while the number of zones in
the ring differs from the replication factor (for example when a zone is
excluded or scaled to zero, and Get places a second copy in another
zone).
Signed-off-by: Alan Protasio <alanprot@gmail.com>
* Add PR number to CHANGELOG
Signed-off-by: Alan Protasio <alanprot@gmail.com>
* ingester: add an integration test for ownership-based limits
Add TestIngesterRingOwnershipLimits: six ingesters across three zones with
a replication factor of 3, two per zone with tokens pinned through a tokens
file so the first of each pair owns 3/4 of its zone's hash space, shuffle
sharding, and a real distributor routing the writes.
A tenant pushing 1600 series against a global limit of 2000:
equal share (today) 1300 of 1600 accepted, the 3/4-share ingesters
pinned at the equal share of 1000
ring ownership 1600 of 1600 accepted, 1174 and 426 per zone
A second tenant with a 3-instance shard (one ingester per zone, so each
owns all of that tenant's hash space) reaches the same global limit on
every arm, and the test asserts its series are held by exactly three
ingesters: with the shares read from the full ring instead of the tenant's
subring, the small-token ingester in its shard would reject most of them.
Expose cortex_ingester_ring_ownership_share{user}, so the share in use is
visible to operators and the test can wait for it rather than sleeping.
The series use random label values, not a sequential run: the FNV-1a hash
Cortex shards series with is skewed enough over "0".."1599" that only 57%
of them fall in the first 3/4 of the token space, which hides the effect.
Publish the e2e framework's container ports on 127.0.0.1 rather than every
interface. The tests already reach services through 127.0.0.1, so a bare
host port only widened who could reach an unauthenticated Cortex on the
machine running them.
Signed-off-by: Alan Protasio <alanprot@gmail.com>
* Fix lint
- maps.Copy instead of a copy loop (modernize).
- go.uber.org/atomic instead of sync/atomic, which faillint blocks.
Signed-off-by: Alan Protasio <alanprot@gmail.com>
* ingester: widen the ownership limits integration test to nine ingesters
Three ingesters per zone instead of two, with tokens pinned so that within
its zone the first owns 1/2 of the hash space and the other two 1/4 each.
The second tenant's shard is now six of the nine, two per zone, so it is a
real subset and ShuffleShard builds an actual subring. Its name is chosen
so the shard is the 1/2-share and one 1/4-share ingester of every zone,
which own 3/4 and 1/4 of that tenant's hash space: shares that exist only
in the subring, where the whole ring would give the first 1/2. Both tenants
now assert both arms, and the expected shares are derived from a ring built
from the same instances rather than hardcoded.
A tenant pushing 3200 series against a global limit of 4000:
equal share whole ring: 2800 accepted, the 1/2-share ingesters
pinned at the equal share of 1333
6-instance shard: 2600 accepted, the 3/4-share
ingesters pinned at their equal share of 2000
ring ownership both: 3200 accepted, 1571/805/824 and 2370/830
Doubled the series count and the limit: at half this scale the margin
between an ingester's load and its limit was about two standard deviations
of how unevenly the series hash over the token space, close enough that the
noise could decide the verdict.
Signed-off-by: Alan Protasio <alanprot@gmail.com>
* ingester: push the whole global limit in the ownership limits test
Each tenant now pushes 4000 series against a global limit of 4000, so every
ingester of its shard ends up at its own limit and the test measures how
much of the limit the tenant can actually use, rather than whether a load
comfortably inside it is rejected.
equal share whole ring 3327/4000 (83.2%), 1/2-share ingesters
pinned at the equal share of 1333
6-instance shard 3021/4000 (75.5%), 3/4-share
ingesters pinned at their equal share of 2000
ring ownership whole ring 3991/4000 (99.8%), 6-shard 3979 (99.5%)
The test asserts at least 95% with ownership-based limits and at most 90%
without. Not 100%: the series do not hash perfectly evenly over the token
space, so an ingester landing marginally over its own limit rejects a few.
Both figures are deterministic, since the label values come from a fixed
seed, and match a calculation over the same hash to within one series.
How much was stored is now read from the ingesters per zone rather than
counted from accepted requests: a request is rejected as a whole even when
some of its series were written, so counting requests understates it.
Signed-off-by: Alan Protasio <alanprot@gmail.com>
---------
Signed-off-by: Alan Protasio <alanprot@gmail.com>1 parent d292d56 commit d823d63
16 files changed
Lines changed: 1494 additions & 3 deletions
File tree
- docs/configuration
- integration
- e2e
- pkg
- cortex
- ingester
- ring
- schemas
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4252 | 4252 | | |
4253 | 4253 | | |
4254 | 4254 | | |
| 4255 | + | |
| 4256 | + | |
| 4257 | + | |
| 4258 | + | |
| 4259 | + | |
| 4260 | + | |
| 4261 | + | |
| 4262 | + | |
| 4263 | + | |
4255 | 4264 | | |
4256 | 4265 | | |
4257 | 4266 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
| 155 | + | |
| 156 | + | |
155 | 157 | | |
156 | 158 | | |
157 | 159 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
355 | 355 | | |
356 | 356 | | |
357 | 357 | | |
358 | | - | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
359 | 361 | | |
360 | | - | |
| 362 | + | |
361 | 363 | | |
362 | 364 | | |
363 | 365 | | |
| |||
0 commit comments