Distributor: stop counting metadata towards the ingestion rate limit - #7779
Distributor: stop counting metadata towards the ingestion rate limit#7779friedrichg wants to merge 1 commit into
Conversation
9ad6f94 to
736dcd0
Compare
Scope note: this affects remote write 1.0 too, and the ~2x argument does not transferThe justification differs per protocol, so it is worth being precise. Remote write 2.0 is the amplification case. Every Remote write 1.0 has no amplification. Prometheus sends metadata once per family, batched, on a timer (
Trade-off I would like input onThis removes rate bounding from the metadata path entirely, for both protocols. Since So for v1 this is closer to a principled cleanup plus a burst fix than to a bug fix, and a reasonable alternative is a dedicated metadata rate limiter rather than excluding metadata from the sample budget. I kept this PR to the simple exclusion because it matches the flag's documented contract and the upstream position that metadata is not a sample (prometheus/prometheus#14407), but I am happy to add a separate limiter instead if reviewers would rather keep backpressure on that path. |
The -distributor.ingestion-rate-limit flag is documented as a limit in samples per second, but metadata was folded into the same budget as samples and exemplars. Metadata is not sample data, and its volume is already bounded separately by -ingester.max-metadata-per-user and -ingester.max-metadata-per-metric. This mattered most for Prometheus Remote Write 2.0, which attaches metadata to every series. A metric family with N series contributed N metadata entries to the budget, so a tenant consumed roughly twice its configured limit for the same data. The ingester instance ingestion rate, used by -ingester.instance-limits.max-ingestion-rate, stops counting metadata for the same reason. Its comment already stated that it mirrored the distributor. The 429 message no longer reports a metadata count, since metadata no longer contributes to exceeding the limit. Metadata carried by a rejected request is still counted as discarded. Upstream Prometheus takes the same position on the sender side: metadata is not a sample and is not counted against max_samples_per_send (prometheus/prometheus#14407). Signed-off-by: Friedrich Gonzalez <1517449+friedrichg@users.noreply.github.com>
736dcd0 to
ed2135f
Compare
Follow-up: this also removes metadata from the instance-level overload valvesLooking at the blast radius more carefully, this change reaches wider than the per-tenant limit, and I do not think all of it is intended. Both instance-level valves read the same EWMA counters this PR stops feeding:
Since That is a different decision from the per-tenant one. The per-tenant limit is documented in samples per second, so excluding metadata matches its stated contract. The instance limits exist to keep a process from being overrun, where the relevant question is work performed rather than sample semantics. What a metadata flood costs after this PRCardinality and memory are still bounded at the ingester: The realistic flood is duplicates, since senders re-send the same metadata every interval. That path passes both asserts and ends at Options
I lean towards option 1 here, with option 2 as a follow-up if operators want explicit metadata backpressure. Happy to push either. |
This comment was marked as outdated.
This comment was marked as outdated.
Correction: the documentation should match the behaviour, not the reverseI am withdrawing the direction of this PR and of my previous two comments.
So the fix should be documentation only. Changing the accounting to satisfy the wording is the wrong way round, and it carries real downsides that I raised on this PR myself:
None of that is worth it to make a help string true when the help string is the thing that is wrong. Consequence for #7760: with the accounting unchanged, the remote write 2.0 amplification that PR describes stays a real problem, and deduplicating per-series metadata during conversion is an appropriate fix for it. I withdraw my earlier claim that this PR removes #7760's motivation. Apologies for the noise there. This PR should therefore be dropped in favour of a documentation-only change to the two flag descriptions, with the generated config reference regenerated to match. |
|
Closing per the correction above: the accounting is intentional and this limit is a total ingestion budget, so the fix belongs in the flag descriptions rather than in the behaviour. Will follow up with a documentation-only change to The remote write 2.0 metadata amplification remains a real problem, and #7760 is an appropriate fix for it. |
What this PR does:
-distributor.ingestion-rate-limitis documented as a limit in samples per second, but metadata was counted in the same budget as samples and exemplars. Metadata is not sample data, and its volume is already bounded by-ingester.max-metadata-per-userand-ingester.max-metadata-per-metric.This applies to both remote write 1.0 and 2.0, since the limit is enforced on the shared
Distributor.Pushpath. 2.0 is affected most, as it attaches metadata to every series, so a tenant consumed roughly twice its configured limit for the same data. But 1.0 senders are affected too: Prometheus sends metadata by default (metadata_config.send, up to 2000 entries per request every minute), and those metadata-only requests are now unrated. The ingester instance rate stops counting metadata too, for consistency (its comment already said it mirrored the distributor).Opened as a draft alternative to #7760, which dedupes metadata during PRW2 conversion instead. Note this PR removes #7760's stated motivation (the ~2x rate limit consumption); #7760's remaining benefits are fewer allocations and less distributor-to-ingester volume, which are real but are efficiency wins rather than a limit-correctness fix. Happy to close this if the dedup is preferred.
Upstream Prometheus takes the same position on the sender side: metadata is not a sample and is not counted against
max_samples_per_send(prometheus/prometheus#14407).Which issue(s) this PR fixes:
N/A
Checklist
CHANGELOG.mdupdateddocs/configuration/v1-guarantees.mdupdated if this PR introduces experimental flags