Add rate limits for group hierarchy listing endpoints
What does this MR do and why?
Applies per-user-or-IP limits to the group hierarchy listing endpoints in the REST API:
| Limit | Endpoints | Key |
|---|---|---|
| 1,000 per minute | GET /groups/:id/subgroups, GET /groups/:id/descendant_groups |
group_tree_api |
| 600 per minute | GET /projects/:id/groups |
project_groups_api |
| 60 per minute, shared | GET /groups/:id/projects/shared, GET /projects/:id/starrers, GET /projects/:id/share_locations |
namespace_relations_api |
| 60 per minute, shared | GET /projects/:id/transfer_locations, GET /groups/:id/transfer_locations |
transfer_locations_api |
The limits are fixed, like the existing delete limits, and are enforced behind the group_hierarchy_read_rate_limit feature flag, which is disabled by default.
The values come from production traffic on 2026-11-24, counted per user or IP address per minute. At these limits:
| Key | Busiest minute | Users or IPs over the limit | Requests rejected that day |
|---|---|---|---|
group_tree_api |
11,505 | 2 | ~47,900 |
project_groups_api |
1,088 | 1 | ~1,300 |
namespace_relations_api |
255 | 6 | ~9,000 |
transfer_locations_api |
17 | 0 | 0 |
GET /projects/:id/groups has its own key because it is much busier than the other relation endpoints: on that day it made up 98% of what a shared 60 per minute limit would have rejected.
References
- Rollout issue: #635777
- Closes #635736
Screenshots or screen recordings
Not applicable, there are no UI changes.
How to set up and validate locally
-
In the Rails console, enable the feature flag:
Feature.enable(:group_hierarchy_read_rate_limit) -
As a user with access, list a project's starrers (
GET /api/v4/projects/:id/starrers) more than 60 times in a minute. -
Confirm that requests over the limit receive a
429response. -
Disable the feature flag and confirm the requests are no longer limited:
Feature.disable(:group_hierarchy_read_rate_limit)
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist.