Skip to content

feat(BA-7363): publish the per-user rate limit to the shared Redis DB - #13784

Draft
jopemachine wants to merge 3 commits into
feature/BA-7362-user-policy-api-request-limitfrom
feature/BA-7363-publish-user-rate-limit
Draft

feat(BA-7363): publish the per-user rate limit to the shared Redis DB#13784
jopemachine wants to merge 3 commits into
feature/BA-7362-user-policy-api-request-limitfrom
feature/BA-7363-publish-user-rate-limit

Conversation

@jopemachine

@jopemachine jopemachine commented Aug 14, 2026

Copy link
Copy Markdown
Member

📚 Stacked PRs

This PR is part of a 5-PR stack. Merge in order:

  1. ⬇️ feat(BA-7364): deliver the login user id in the auth response #13777feat(BA-7364): deliver the login user id in the auth response
  2. ⬇️ feat(BA-7365): key the rate limit counter by user id #13778feat(BA-7365): key the rate limit counter by user id
  3. ⬇️ feat(BA-7362): move the per-user API rate limit to the user resource policy #13779feat(BA-7362): move the per-user API rate limit to the user resource policy
  4. 👉 feat(BA-7363): publish the per-user rate limit to the shared Redis DB #13784feat(BA-7363): publish the per-user rate limit to the shared Redis DB ← you are here
  5. ⬇️ feat(BA-7365): add a per-user rate limit middleware to the web server #13771feat(BA-7365): add a per-user rate limit middleware to the web server

Only the final tip (#13771) is guaranteed to build / pass CI; intermediate PRs are logical slices for reviewability.

Summary

  • Add set_user_rate_limit() / get_user_rate_limit() to ValkeyRateLimitClient, storing the value under a user-rate-limit.<user_id> key in the rate limit DB that already holds the rolling counters.
  • The manager's rate limit middleware republishes the user's policy value on every authorized request. It resolves that value per request anyway, so the published copy never goes stale: a lowered limit reaches the web server on the user's next proxied request.
  • The TTL is the rate limit window, so a limit that stops being republished expires at the same time its rolling counter would.

The web server reads this value instead of carrying the limit in its session token, which would have frozen it at login time for up to a week.

Resolves BA-7363.

The web server needs the limit to reject over-limit requests before they
reach the manager, and reading it from the session would freeze it at login
time. The manager's rate limit middleware resolves the policy value on every
authorized request anyway, so it republishes the value there under a
`user-rate-limit.` key with the rate limit window as its TTL. A limit that
stops being republished expires within that window, which is also when its
rolling counter would expire.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@jopemachine
jopemachine requested a review from a team as a code owner August 14, 2026 14:20
Co-authored-by: octodog <mu001@lablup.com>
@jopemachine
jopemachine marked this pull request as draft August 14, 2026 14:23
@github-actions github-actions Bot added size:L 100~500 LoC area:docs Documentations and removed size:M 30~100 LoC labels Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:docs Documentations comp:common Related to Common component comp:manager Related to Manager component size:L 100~500 LoC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant