Skip to content

Resolve "Improve performance of users API under load"

What does this MR do and why?

This MR is focusing on improving the performance of /api/v4/users endpoint when called by an admin user.

It was noticed that for regular users, the TTFB P90 was under expected range of 200ms, while for admin users, it was too high.

Admin User

NAME         | RPS    | RPS RESULT           | TTFB AVG  | TTFB P90            | REQ STATUS     | RESULT
-------------|--------|----------------------|-----------|---------------------|----------------|-----------------
api_v4_users | 1000/s | 523.11/s (>400.00/s) | 1777.00ms | 4730.38ms (<5500ms) | 100.00% (>99%) | Passed¹

Non-Admin User

NAME         | RPS    | RPS RESULT           | TTFB AVG | TTFB P90          | REQ STATUS     | RESULT
-------------|--------|----------------------|----------|-------------------|----------------|-----------------
api_v4_users | 1000/s | 996.05/s (>400.00/s) | 32.95ms  | 36.26ms (<5500ms) | 100.00% (>99%) | Passed¹

Note: The above results are for 50k architecture, refer #346601 (comment 1010359598).

The reason for the high response time for admin is that the API is returning lot more data of users when an admin calls the API in comparison to when a regular user calls it. For this additional data there are additional database queries being fired.
In the admin flow, there were several N+1 queries and a query where JOIN was being used which was not necessary. These were affecting the performance, so in this PR, we are preloading some data instead of making N queries.

Screenshots or screen recordings

These are strongly recommended to assist reviewers and reduce the time to merge your change.

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #346601 (closed)

Edited by Hitesh Raghuvanshi

Merge request reports

Loading