unkeyed / unkey

Open source API management platform
https://go.unkey.com
Other
2.76k stars 278 forks source link

Rootkeys API keys take long to create #1959

Closed Flo4604 closed 1 month ago

Flo4604 commented 1 month ago

Preliminary Checks

Reproduction / Replay Link (Optional)

No response

Issue Summary

Creating a rootkey can take a very long time, in this case 16seconds. The more permissions the longer it takes

https://github.com/user-attachments/assets/ef91b1ed-2362-430e-8aa4-e58c66508f11

Steps to Reproduce

Create a rootkey with as many permissions selected as possible.

Expected behavior

It takes less time

Other information

No response

Screenshots

No response

Version info

- OS: 15.0 Beta (24A5289h)
Flo4604 commented 1 month ago

I just added this ticket for tracking purposes, as I've already worked on a PR for this.

The most obvious issue for me seems to be this code in the createRootKey code: 46569 14720

It loops over each selected permission, and does a single query which is unnecessary overhead, also ingests audit logs one by one instead of batching them all at the same time.

linear[bot] commented 1 month ago

ENG-1273 Rootkeys API keys take long to create

perkinsjr commented 1 month ago

Thanks for opening the issue @Flo4604 I just assigned it to you just so no one else works on it as I know you have a PR 🙇