Skip to content

Distinguish per-key from whole-queue rate limiting in matching hook#10943

Closed
rkannan82 wants to merge 5 commits into
temporalio:mainfrom
rkannan82:kannan/wci-per-key-rate-limit
Closed

Distinguish per-key from whole-queue rate limiting in matching hook#10943
rkannan82 wants to merge 5 commits into
temporalio:mainfrom
rkannan82:kannan/wci-per-key-rate-limit

Conversation

@rkannan82

@rkannan82 rkannan82 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

What

Distinguishes per-fairness-key rate limiting from whole-queue rate limiting by introducing a new enum constant called SyncMatchOutcomeFairnessKeyRateLimited. This is now propagated to the matching hook API.

Why

PR #10045 added SyncMatchOutcomeRateLimited but didn't distinguish whole-queue from per-key rate limits. These have different scaling implications: whole-queue limits mean more workers can't help, but per-key limits doesn't mean you cannot scale up.

How did you test it?

Unit tests: TestMatchTaskImmediatelyFairnessKeyRateLimited verifies per-key rate limiting returns the distinct outcome; existing TestMatchTaskImmediatelyRateLimited covers the whole-queue case.

🤖 Generated with Claude Code

Per-fairness-key rate limiting should not suppress WCI scaling because
other keys may still need workers. Only whole-queue rate limits indicate
that adding more workers genuinely cannot help.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add SyncMatchOutcomeFairnessKeyRateLimited to hook enum instead of
  collapsing per-key rate limiting into NotMatched. Let hooks decide
  how to handle each outcome.
- Rename syncMatchPerKeyRateLimited to syncMatchFairnessKeyRateLimited.
- Use switch in MatchTaskImmediately so new enum values are handled
  explicitly.
- Replace wholeQueueLimited bool return from findMatch with a
  rateLimitKind enum for a clearer API.
- Remove hook-consumer-specific references from comments.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@rkannan82 rkannan82 force-pushed the kannan/wci-per-key-rate-limit branch from 3b77442 to 45d47b7 Compare July 7, 2026 04:54
@rkannan82 rkannan82 marked this pull request as ready for review July 7, 2026 04:55
@rkannan82 rkannan82 requested review from a team as code owners July 7, 2026 04:55
@rkannan82 rkannan82 requested a review from dnr July 7, 2026 04:56
@rkannan82 rkannan82 changed the title Distinguish per-key from whole-queue rate limiting in WCI hook Distinguish per-key from whole-queue rate limiting in matching hook Jul 7, 2026
rkannan82 and others added 2 commits July 6, 2026 22:26
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
// A poller was available but whole-queue rate limiting blocked the match.
SyncMatchOutcomeRateLimited
// A poller was available but per-fairness-key rate limiting blocked the match.
SyncMatchOutcomeFairnessKeyRateLimited

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.

I'd rather not put this in the api like this:

  1. the existing fairness key rate limit is an interim feature that should be replaced by flow control features, which will be harder to handle this way
  2. at this point, the fairness key rate limit will block the whole queue (priority level, at least), so there's nothing different to be done from a scaler pov

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok. Closing this PR.

@rkannan82 rkannan82 closed this Jul 7, 2026
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