Skip to content

Add fairness to matching RPS rate limiter#10370

Draft
prathyushpv wants to merge 3 commits into
mainfrom
ppv/matchingFairness
Draft

Add fairness to matching RPS rate limiter#10370
prathyushpv wants to merge 3 commits into
mainfrom
ppv/matchingFairness

Conversation

@prathyushpv
Copy link
Copy Markdown
Contributor

What changed?

Add fairness mechanism to matching rps rate limiter. Each namespace will have a matching RPS quota per matching host based on this formula

NamespaceQuota = MatchingRPS * MatchingNamespaceFairShare.

MatchingNamespaceFairShare is a namespace-level float in [0, 1], configurable through dynamic config. If a namespace's request rate exceeds this quota, those extra requests will be deprioritized. If matching rps rate limiter starts to throttle requests, these deprioritized requests will be throttled first. This will prevent unbalanced load from a namespace affecting other namespaces in a matching host. Values outside the open interval (0, 1) disable the mechanism for that namespace (default 0 = off).

Also fixes the host RPS interceptor (common/rpc/interceptor/rate_limit.go) to forward the CallerName header into quotas.Request. The fairness priority function reads req.Caller to route to the right per-namespace bucket; without this fix the mechanism (and the equivalent one in #10134) is inert.

Why?

To prevent noisy neighbour issues in matching rps rate limiter.

How did you test it?

  • built
  • run locally and tested manually
  • covered by existing tests
  • added new unit test(s)
  • added new functional test(s)

Potential risks

The interceptor fix activates the history fairness mechanism in #10134 for the first time. Both flags default off, so no behavior change unless an operator explicitly opts in per namespace.

Each namespace gets a per-host fair-share quota:
share(ns) = MatchingRPS * MatchingNamespaceFairShare(ns).

Requests from namespaces exceeding their share are deprioritized so
they're throttled first when matching is at its host RPS limit, mirroring
the history fairness PR (#10134). The single namespace-level float config
also acts as the on/off switch — values outside (0, 1) disable fairness
for that namespace; default 0 = off.

Also fixes the host RPS interceptor to forward the CallerName header into
quotas.Request, which the priority fairness functions read to route to
per-namespace buckets. Without this, both this PR and #10134 would be
inert in production.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant