Repository navigation
Conversation
cortex_ring_member_ownership_percent is computed by countTokens(), which
merges the tokens of all zones into a single sorted list, so each token
owns the distance back to the previous token from any zone.
With zone-aware replication a write is routed within a single zone: in
zone A, member X serves the hash range from the previous zone-A token to
X's own token. The existing metric therefore depends on where the other
zones' tokens happen to fall, and does not report the range a member
actually serves. An uneven per-zone distribution is invisible: a member
can sit at the zone average by this metric while serving a noticeably
larger share of its own zone, which is what pushes the hottest members of
a zone into per-member limits first.
Add cortex_ring_member_zonal_ownership_percent{name, member, zone},
reporting the fraction of its own zone's token space owned by each
member, so the values within a zone sum to 1 and skew can be computed as
max/avg per zone. It reuses countTokensByAz(), which already existed for
the /ring page, and is reported only when ring detailed metrics and zone
awareness are both enabled. Stale series are deleted when a member leaves
the ring or moves to another zone, mirroring the existing handling for
cortex_ring_member_ownership_percent.
countTokensByAz() now reads the ringTokensByZone computed by
updateRingState instead of recomputing the per-zone token lists on every
call, matching countTokens(), which already reads the cached ringTokens.
RingCompare returns Different for any change to the instance set, zones
or tokens, so on the paths that reach updateRingMetrics the cached value
is token-identical to a fresh computation. This halves the cost of the
function and makes the /ring page cheaper too.
Signed-off-by: Ben Ye <benye@amazon.com>
friedrichg
approved these changes
Nov 3, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does:
cortex_ring_member_ownership_percentis computed bycountTokens(), which merges the tokens of all zones into a single sorted list, so each token owns the distance back to the previous token from any zone.With zone-aware replication a write is routed within a single zone: in zone A, member X serves the hash range from the previous zone-A token to X's own token. The existing metric therefore depends on where the other zones' tokens happen to fall and does not report the range a member actually serves. An uneven per-zone token distribution, for example after a scale-down, is invisible: a member can sit at the zone average by this metric while serving a noticeably larger share of its own zone, which is what pushes the hottest members of a zone into per-member limits first.
This PR adds:
The value is the fraction of its own zone's token space owned by the member, so the values within a zone sum to 1. Skew per zone can be computed as:
(The inner
max by (name, member, zone)collapses the identical series reported by every component holding a ring client.)Details:
countTokensByAz(), which was previously only used by the/ringpage.detailed_metrics_enabled) and zone awareness are both enabled. Without zone awareness writes are not routed per zone, so a per-zone ownership value would be misleading.cortex_ring_member_ownership_percent._percentsuffix matches the siblingcortex_ring_member_ownership_percent, which also reports a 0–1 value.countTokensByAz()now reads theringTokensByZonealready computed byupdateRingStateinstead of recomputing the per-zone token lists on every call, matchingcountTokens(), which already reads the cachedringTokens.RingComparereturnsDifferentfor any change to the instance set, zones or tokens, so on every path that reachesupdateRingMetricsthe cached value is token-identical to a fresh computation. On a 300 instance x 512 token x 3 zone ring this takescountTokensByAz()from ~41ms / 708KB to ~23ms / 48KB per call, which also makes the/ringpage cheaper.The detailed metrics block only runs on topology changes (heartbeat-only updates return
EqualButStatesAndTimestampsand skip it), so the added cost is onecountTokensByAz()pass per topology change per ring client.Which issue(s) this PR fixes:
N/A
Checklist
CHANGELOG.mdupdated - the order of entries should be[CHANGE],[FEATURE],[ENHANCEMENT],[BUGFIX]docs/configuration/v1-guarantees.mdupdated if this PR introduces experimental flags (N/A: no new flags)