Add per-user rate limits for member management actions

What does this MR do and why?

Adds per-user limits to member management actions, for groups and projects:

Limit Applies to Key
300 per minute per user per group or project Adding and updating members, inviting and updating invitations, and approving access requests, in the REST API, GraphQL bulk updates and the web interface member_add_update
10 per minute per user per group or project Resending invitations, and requesting access in the REST API and the web interface member_notification_email
5 per minute per user Importing project members (POST /projects/:id/import_project_members/:project_id) member_import

It also applies the existing, configurable members_delete limit to removing members in the web interface.

This brings these actions in line with the existing limits on similar actions.

  • The three new limits are staged rules behind the member_mutation_rate_limit feature flag, which is disabled by default. While the flag is off, requests over the limit are logged but not blocked. The web members_delete check is skipped while the flag is off, because that limit is already enforced in the REST API.
  • Adding or updating several members at once is charged one unit per member, capped at the limit so one large request can still succeed. That covers POST /:id/members, POST /:id/invitations and the groupMemberBulkUpdate and projectMemberBulkUpdate mutations.
  • The web controllers check the limits after their authorization checks, so a user without rights gets 404 and doesn't count. request_access has no authorization step, so it counts before the already-a-member check.
  • Throttled web requests redirect back with a flash message. XHR requests, such as role changes in the members table, get a 429.
  • Each rule has a contract entry in config/rate_limits/unowned.yaml, and the docs list them in the non-configurable rate limits.

Production traffic

Counted per user per minute on 2026-11-30.

Limit Busiest minute Over the limit
Add and update, per user per group or project (REST, 3 sampled hours) 304 1 user in 1 minute, 4 requests
Notification emails, per user (the 18 hours that returned) 2 none
Import, per user 3 none

The first proposal of 60 per minute for adding and updating would have put 1 to 5 users over in each 10-minute window of the sampled hours, and some of them were syncing roles successfully. Most of the heavy traffic is automation: failed adds (400, or 409 for existing members) and role updates that run one member at a time.

References

  • Rollout issue: #635774
  • Closes #635732

Screenshots or screen recordings

Not applicable, there are no UI changes.

How to set up and validate locally

  1. As a maintainer, update members (PUT /api/v4/groups/:id/members/:user_id) more than 300 times in a minute.

  2. With the flag disabled, the requests aren't blocked. log/api_json.log shows applimiter_member_add_update:limit_member_adds_and_updates_by_source_user_log in rate_limit_state.

  3. Enable the feature flag in the Rails console:

    Feature.enable(:member_mutation_rate_limit)
  4. Repeat the requests. Requests over the limit receive a 429 response.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Shubham Kumar

Merge request reports

Loading
Loading