feat(BA-7365): add a per-user rate limit middleware to the web server - #13771
Draft
jopemachine wants to merge 3 commits into
Draft
Conversation
jopemachine
added a commit
that referenced
this pull request
Aug 13, 2026
This was referenced Aug 13, 2026
jopemachine
changed the base branch from
feature/BA-7364-deliver-user-id-to-webserver-session
to
main
August 13, 2026 09:19
jopemachine
force-pushed
the
feature/BA-7365-webserver-user-rate-limit-middleware
branch
from
August 14, 2026 05:57
6f6de7b to
276aea8
Compare
jopemachine
changed the base branch from
main
to
feature/BA-7365-user-keyed-rate-limit-counter
August 14, 2026 05:57
jopemachine
force-pushed
the
feature/BA-7365-user-keyed-rate-limit-counter
branch
from
August 14, 2026 05:58
3f23516 to
ef4b9b6
Compare
jopemachine
force-pushed
the
feature/BA-7365-webserver-user-rate-limit-middleware
branch
from
August 14, 2026 05:58
276aea8 to
435c734
Compare
This was referenced Aug 14, 2026
jopemachine
force-pushed
the
feature/BA-7365-user-keyed-rate-limit-counter
branch
3 times, most recently
from
August 14, 2026 14:08
1b8bfd3 to
ecf3a77
Compare
jopemachine
force-pushed
the
feature/BA-7365-webserver-user-rate-limit-middleware
branch
from
August 14, 2026 14:20
435c734 to
9429438
Compare
Requests proxied to the manager (`/func/*`) are counted against the login user's rolling counter and rejected with HTTP 429 once the session's rate limit is passed, so floods no longer reach the manager. The middleware is registered after `setup_session()` because it reads the session storage the session middleware installs. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The limit is no longer carried in the session token, so the middleware reads the value the manager publishes for the user. A user with no published limit passes through: the manager republishes on every authorized request, so the value is missing only before a user's first proxied request or after a window of inactivity, and the manager-side limiter covers both. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
jopemachine
force-pushed
the
feature/BA-7365-webserver-user-rate-limit-middleware
branch
from
August 14, 2026 14:20
9429438 to
8c8b746
Compare
jopemachine
changed the base branch from
feature/BA-7365-user-keyed-rate-limit-counter
to
feature/BA-7363-publish-user-rate-limit
August 14, 2026 14:20
Co-authored-by: octodog <mu001@lablup.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📚 Stacked PRs
This PR is part of a 5-PR stack. Merge in order:
feat(BA-7364): deliver the login user id in the auth responsefeat(BA-7365): key the rate limit counter by user idfeat(BA-7362): move the per-user API rate limit to the user resource policyfeat(BA-7363): publish the per-user rate limit to the shared Redis DBfeat(BA-7365): add a per-user rate limit middleware to the web server← you are hereOnly the final tip (#13771) is guaranteed to build / pass CI; intermediate PRs are logical slices for reviewability.
Summary
/func/*) against the login user's rolling counter and rejects over-limit requests with HTTP 429, so floods no longer consume manager resources (auth DB lookup, Valkey ops).rate_limitcarried in the session;Nonemeans counted but never rejected. Unauthenticated requests and sessions from managers that do not send the user id yet pass through unchanged.Verified against a live cluster (manager + web server on this branch, halfstack Valkey/PostgreSQL): the counter is a single
user.<uuid>key; 429 once the counter passes the limit;rate_limit = NULLcounted but never rejected; unauthenticated/func/*, non-/funcpaths and sessions withoutuser_idpass through uncounted; the manager-only path allows exactlyrate_limitrequests.Resolves BA-7365.