Improve performance of Project Merge Requests API under load into next tier
<!--IssueSummary start--> <details> <summary> Everyone can contribute. [Help move this issue forward](https://handbook.gitlab.com/handbook/marketing/developer-relations/contributor-success/community-contributors-workflows/#contributor-links) while earning points, leveling up and collecting rewards. </summary> - [Close this issue](https://contributors.gitlab.com/manage-issue?action=close&projectId=278964&issueIid=526537) </details> <!--IssueSummary end--> The TTFB (Time to First Byte) of the Project Merge Requests API is slightly over [our performance target](https://about.gitlab.com/handbook/engineering/quality/issue-triage/#severity) under load: ``` * Environment: 25k * Environment Version: 17.11.0-pre `fd3e40cbbcf` * Option: 60s_500rps * Date: 2025-03-24 * Run Time: 1h 35m 24.77s (Start: 04:54:20 UTC, End: 06:29:45 UTC) * GPT Version: v2.15.0 NAME | RPS | RPS RESULT | TTFB AVG | TTFB P90 | REQ STATUS | RESULT ---------------------------------------------------------|-------|----------------------|-----------|-----------------------|----------------|--------- api_v4_projects_merge_requests | 500/s | 492.55/s (>400.00/s) | 184.79ms | 233.45ms (<200ms) | 100.00% (>99%) | FAILED² ``` ![Screenshot_2025-03-24_at_12.22.47](/uploads/d2e130e8fabc7a81ed15b61e1f0d3fca/Screenshot_2025-03-24_at_12.22.47.png) In other environments like [10k](https://10k.testbed.gitlab.net/-/grafana/d/J0ysCtCWz/gpt-test-results?orgId=1&from=now-15d&to=now&timezone=browser&var-test_name=api_v4_projects_merge_requests&var-gpt_custom_tag=$__all), the failures are less common: ![Screenshot_2025-03-24_at_12.23.34](/uploads/0f85bf60b884a518b7d0f57e01c829d8/Screenshot_2025-03-24_at_12.23.34.png) ### Test Details Testing was done on our [10k Reference Architecture](https://docs.gitlab.com/ee/administration/reference_architectures/10k_users.html) environment with [our lab condition GitLab Performance Tool pipeline](https://gitlab.com/gitlab-org/quality/performance). The project being tested is a copy of [gitlabhq](https://staging.gitlab.com/gpt/large_projects/gitlabhq1/) (tarball can be found [here](https://gitlab.com/gitlab-org/quality/performance-data/-/blob/master/projects_export/gitlabhq_export_13.0.0.tar.gz)). GitLab Performance Tool tests information is listed at [Current test details](https://gitlab.com/gitlab-org/quality/performance/-/wikis/current-test-details) page. The latest GitLab Performance pipeline results can always be found [here](https://gitlab.com/gitlab-org/quality/performance/-/wikis/Benchmarks/Latest/10k). Through this page full Server Metrics can be found via the `Metrics Dashboard` link on that page. As per our [performance targets](https://handbook.gitlab.com/handbook/engineering/infrastructure/engineering-productivity/issue-triage/#severity) this endpoint's TTFB metric is above the target of 200 ms which is ~"severity::4". Task is to improve the endpoint's performance into next tier.
issue