unkeyed / unkey

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

Permission updates in the UI are slow #904

Open chronark opened 7 months ago

chronark commented 7 months ago

Preliminary Checks

Reproduction / Replay Link (Optional)

No response

Issue Summary

We're looping through all required permissions and doing a network roundtrip for each. https://github.com/unkeyed/unkey/blob/6c516c33db02312dd95a10db64941500365154d1/apps/web/lib/trpc/routers/permission.ts#L123

Steps to Reproduce

  1. https://unkey.dev/app/settings/root-keys/new
  2. add some permissions
  3. save

Expected behavior

It should be much faster

Other information

No response

Screenshots

No response

Version info

irrelevant
linear[bot] commented 7 months ago

ENG-497 Permission updates in the UI are slow

Praashh commented 7 months ago

Hey, I have a doubt, created a new root key and I feel it's depend on the backend. is'nt it ?

chronark commented 7 months ago

can you elaborate?

Praashh commented 7 months ago

I tried to create a root key for test the speed, I feel UI updation slow because of backend response. correct me if I am wrong please.

chronark commented 7 months ago

yes it's the backend that is slow, I linked the code above

Praashh commented 7 months ago

So that means, we have to optimize the backend as well ?

chronark commented 7 months ago

the only bottleneck is in the backend, the ui just sends a trpc request

Praashh commented 7 months ago

Thanks for clearing. It takes some time understand the problem statement. Got it now, Can I work on that or someone from unkey is already working upon that?

chronark commented 7 months ago

sure, go ahead

AkshayBandi027 commented 7 months ago

hey @chronark, As mentioned above We're looping through all required permissions and doing a network roundtrip for each., I guess your talking about

image

we can make use of Promise.all() for concurrently doing a network request

image

Is this related as mentioned above or i am going in wrong direction ?

chronark commented 7 months ago

Yeah, I deliberately didn't do a promise.all, cause apparently that's an issue with planetscale

I haven't looked much deeper though and just accepted that it might be a bit slower for now.

I'm reworking permissions a little bit right now, and adding roles, potentially we don't even need to upsert in parallel anymore