Skip to content

Add fairness to history RPS rate limiter#10134

Open
prathyushpv wants to merge 3 commits intomainfrom
ppv/nsFairness
Open

Add fairness to history RPS rate limiter#10134
prathyushpv wants to merge 3 commits intomainfrom
ppv/nsFairness

Conversation

@prathyushpv
Copy link
Copy Markdown
Contributor

What changed?

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

NamespaceQuota = FrontendRPSLimit * HistoryShardsInHost/TotalShards * Multiplier.

This multiplier is configurable through dynamic config. If a namespace's request rate exceeds this quota, those extra requests will be deprioritized. If history rps rate limiter starts to thorttle requests, these deprioritized requests will be throttled first. This will prevent unbalance load from a namespace affecting other namespaces in a history host.

Why?

To prevent noisy neighbour issues in history 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)

@prathyushpv prathyushpv requested review from a team as code owners April 30, 2026 16:51
@yycptt yycptt requested a review from awln-temporal April 30, 2026 18:50
Comment thread service/history/fx.go
return preemptablePriority
}
callerTypePri := configs.RequestToPriority(req)
if !enabled() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this check be moved above checking Operator/Preemptable priority?

Comment thread service/history/fx.go
ownershipBasedQuotaScaler,
nil,
func(string) int { return 0 },
config.FrontendGlobalNamespaceRPS,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be HistoryGlobalNamespaceRPS ? I assume it's mostly fine to share dynamic configs, considering frontend is more lightweight, but should we document that this config is used for History RPS rate limiting as well?

Comment thread service/history/fx.go
}
metrics.ServiceRequestsNamespaceFairnessDemoted.With(metricsHandler).Record(
1,
metrics.NamespaceTag(req.Caller),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we include the demoted priority value as well as a tag?

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.

2 participants