Hi Descope Team, We have implemented the FGA cache...
# ask-a-descoper
a
Hi Descope Team, We have implemented the FGA cache using the
descope/authzcache
Docker image as described in the documentation: β€’ https://hub.docker.com/r/descope/authzcache β€’ https://docs.descope.com/authorization/fga-cache We are observing unexpected behavior when using the FGA cache: 1. When we do NOT configure the FGA cache URL in the Descope client, FGA checks work correctly and return expected results. 2. When we configure the FGA cache URL, we observe: β€’ Increased latency compared to direct FGA calls, Also it worked when less number of relations to be pass to check. but if its more than 500 relation check at once, it takes time. will share logs from the cache container if needed. Can you please help. cc- @Mike Hudson @Kenneth Knoll
m
looping in @Yosi Haran here
y
Hey @Arif, thanks for the feedback! This is an interesting batch check case, I'll look into improving the performance for large queries like this and keep you posted
a
Thanks for quick response. keep me posted.
y
We found a possible performance optimization we can implement around the internal locking logic when there are many checks to perform from the same call. We are working on it and will let you know once it's ready so that you can update the image, I'm hopefull you will see better results with it πŸ™
πŸ™Œ 3
a
@Yosi Haran -We’d appreciate it if you could share an expected date for these changes available.
y
Hey Arif, sorry for missing this message: should have the possible fix and additional metrics feature to allow us to better debug and improve performance in the upcoming week πŸ™
k
@Mike Hudson this is the thread, not whatever one you were referencing
Hi @Yosi Haran do you have any update on timing for this? I believe @Mike Hudson was going to check back today so apologies if it's a duplicate request.
@Yosi Haran checking back on this. Any update?
y
Hey @Kenneth Knoll, no worries and sorry for the delay. Everything is done development wise, but due to special circumstances in our region this week we had to push the deployment schedule a little bit forward, should be deployed next week, thanks again for your patience πŸ™
πŸ™ 1
k
Oh gosh, yes of course...completely understand. Hope all is well/okay. Thanks for the update and will talk to you next week.
πŸ™ 1
πŸ™†β€β™‚οΈ 1
y
Thanks @Kenneth Knoll! And just to be clear, we are still working at normal capacity, and available for support and critical fixes - we are only delaying the deploy cycle by 1 week πŸ™
πŸ’― 1
k
No misinterpretation in the slightest! We appreciate you guys!
πŸ€— 1
Hi @Yosi Haran do you have an update on timing for this week?
y
Hey @Kenneth Knoll and @Arif, the fix and metrics to help us debug potential additional issues should be available in docker shortly, I am waiting for final confirmation and will update you as soon as it’s available, should be today or at the absolute latest tmrw πŸ™
k
Great, thanks @Yosi Haran. FYI @Mike Hudson @Reshma
y
πŸ™Œ 2
πŸŽ‰ 1
a
@Yosi Haran - Thanks for the update, we will validate and let you know.
πŸ™ 1
@Vivek Sharma
v
We are still facing latency issue when we configure FGA cache URL. If needed we can share the container logs. Can you please help here? CC - @Mike Hudson @Kenneth Knoll
y
Thanks Vivek, will check it out shortly πŸ™
Hey Vivek, I took a look at the duration reported in the logs, and the longest performance I saw was
208ms
, during a cache miss, which is reasonable run time for a network request, and I see most requests taking under
1ms
, which means they are returning directly from the local cache. Perhaps there is an external issue related to the Prisma database connection which might be configured differently when authzcache is used? Maybe threads are not being closed properly? The failures I saw in the logs did not seem related to authzcache, but to Postgress. After my manual analysis, I ran an analysis using Claude Code and verified that it's conclusion about authzcache logs, which I am familiar with, is correct. I cannot verify the conclusions about the service logs, but perhaps it will be useful for you? Please see the analysis below and let me know if it makes sense πŸ™
Copy code
authzcache performance (from dev-auth-cache-logs.csv)

  Extracting all gRPC durations from the Check calls:

  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚   Time   β”‚ Method β”‚ Duration β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”‚ 07:54:06 β”‚ Check  β”‚ 1ms      β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”‚ 07:54:26 β”‚ Check  β”‚ 1ms      β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”‚ 07:54:26 β”‚ Check  β”‚ 1ms      β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”‚ 07:54:29 β”‚ Check  β”‚ 1ms      β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”‚ 07:54:29 β”‚ Check  β”‚ 1ms      β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”‚ 07:54:48 β”‚ Check  β”‚ 33ms     β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”‚ 07:54:50 β”‚ Check  β”‚ 200ms    β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”‚ 07:54:50 β”‚ Check  β”‚ 208ms    β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”‚ 07:54:51 β”‚ Check  β”‚ 23ms     β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”‚ 07:55:06 β”‚ Check  β”‚ 132ms    β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”‚ 07:55:26 β”‚ Check  β”‚ 18ms     β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”‚ 07:55:26 β”‚ Check  β”‚ 1ms      β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”‚ 07:55:28 β”‚ Check  β”‚ 1ms      β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”‚ 07:55:29 β”‚ Check  β”‚ 1ms      β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”‚ 07:55:49 β”‚ Check  β”‚ 1ms      β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”‚ 07:55:49 β”‚ Check  β”‚ 1ms      β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”‚ 07:55:50 β”‚ Check  β”‚ 5ms      β”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

  The vast majority of Check calls complete in 1-5ms. The occasional 100-200ms calls are likely cache misses that proxy to the remote Descope server β€” entirely normal behavior. Write operations (CreateFGARelations, DeleteFGARelations) also
   complete quickly at 29-34ms.

  The "idle-session timeout" errors (from dev-service-action-logs.csv)

  The "terminating connection due to idle-session timeout" errors at lines 364-383 are PostgreSQL errors (SqlState E57P05), NOT authzcache errors. They come from the DatabaseService / Prisma client within the actions service itself:

  prisma:error: Error in PostgreSQL connection: Error {
    severity: "FATAL",
    code: SqlState(E57P05),
    message: "terminating connection due to idle-session timeout"
  }

  These occur at 07:58:00-07:58:01 (6 errors) and 07:59:50 (2 errors). Their Azure PostgreSQL server (aptly-pg-server-dev.postgres.database.azure.com) is killing idle connections in Prisma's connection pool.

  Later at 08:13:29, the service restarts and fails entirely with P1001: Can't reach database server β€” the PostgreSQL server is completely unreachable.

  What's actually happening

  1. The client's PostgreSQL has idle_session_timeout configured β€” it kills connections that sit idle in Prisma's pool. When the service tries to use a killed connection, it gets the FATAL error.
  2. Their database becomes entirely unreachable at ~08:13, causing bootstrap failures and crash loops.
  3. They're checking permissions for 1,206 actions per request (visible in multiple log entries like "Checking permissions for 1206 actions"). Even at 1-5ms per authzcache call, that adds up β€” but it's the sheer volume, not authzcache
  latency.

  Verdict

  authzcache is fast and healthy β€” 1-5ms typical response times. The latency/timeout issues are entirely on the client's infrastructure side:

  - Root cause: Their Azure PostgreSQL server's idle_session_timeout setting is killing pooled connections, and the database is intermittently unreachable.
  - Recommended actions for the client:
    a. Check/increase the idle_session_timeout setting on their Azure PostgreSQL server
    b. Configure Prisma's connection pool to handle stale connections (e.g., connection_limit, pool_timeout, or connection health checks)
    c. Investigate why their database becomes completely unreachable (network/firewall/Azure scaling issue)
@Vivek Sharma Please see above, forgot to tag you in the original msg πŸ™‚πŸ™
v
@Yosi Haran That PostgreSQL is the error from extra connection error. But any findings on the Authz Cache logs?
y
The logs are showing normal response times: ~1ms for cached responses, and ~20-200ms for remote fetches...
So, it's looking normal... can you perhaps provide a bit more data or client-side logs which show extended latency when using authzcache? πŸ™
v
Whenever we hit an API where it is using descope client with FGA cache it gets timed out
y
Hmmm this is odd... and it's not happening when calling authzservice directly (without the FGA cache)?
v
Correct
πŸ‘ 1
y
Are you perhaps using more aggressive timeout values when using FGA cache? i.e. is the only change in configuration supplying the fga cache url, or are there other configuration changes you are making? Can you please verify this? πŸ™
I am also continuing further analysis of the authzcache to make sure I didn't miss anything and will update if I see anything new...
Also, perhaps you can provide a larger log window for the authzcache? I double-verified that I didn't miss any long running request in the logs, e.g. a request that started but didn't report duration, but all "starts" are showing an "end" matching with the same RID, and all latencies look good
v
@Yosi Haran Yes we are only passing cache URL.
πŸ‘ 1
y
Then perhaps I can ask for a larger authzcache log window? Maybe the requests in the specific log file were quick but others not shown here were slow? πŸ™
v
Sure. As it was breaking changes I reverted it back. I will need to redeploy and fetch the logs so give me sometime :)
@Yosi Haran Please find the attached logs. Let me know anything else is required from my end
y
Thanks, checking again πŸ™
I can see all 29 requests have matching start+end, and durations are looking good, summary listed below. Nothing pointing at higher latency in the updated logs either, I'm afraid... Perhaps you can point to to the specific service-side log which indicates that latency is higher?
Copy code
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚   Duration   β”‚ Count β”‚                 Details                 β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”‚ 0ms (sub-ms) β”‚ 2     β”‚ 109Β΅s, 112Β΅s β€” quick cache hits.        β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”‚ 1-2ms        β”‚ 14    β”‚ Normal cache hits                       β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”‚ 25-32ms      β”‚ 5     β”‚ Write ops (Create/Delete FGA) + 1 miss  β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”‚ 108-186ms    β”‚ 5     β”‚ (Larger) Cache misses proxied to remote β”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
I am consulting with @Eliya Sadan, we think it might actually be a too aggressive timeout on the Node-SDK side, causing the FGA cache call to timeout too quickly and then fallback to a direct call, which will cause unnecessary added latency, We've released a version to address this which should be available shortly, I will let you know once it's available so you can update the SDK πŸ™ Additionally, we added more analytics to the authzcache docker image, which I will share an updated version of soon. This will not resolve the issue, but will help us view aggregated performance data for checks more easily.
πŸ™Œ 1
πŸ‘ 1
v
Great! @Yosi Haran Thanks do let us know
πŸ’― 1
y
Hey @Vivek Sharma, both the Descope Node SDK and the Descope authzcache docker image have been updated successfully, please update and let us know if it helps πŸ™
v
Sure, Let me check and will update you shortly on this
@Yosi Haran Unfortunately still the same result. Attaching logs for your reference
k
@Yosi Haran @Eliya Sadan Do you have what you need from us? Any other questions to help troubleshoot/resolve? cc @Vivek Sharma @Mike Hudson
y
Oh sorry, I missed the msg yesterday, will check soon, but just to verify, can you please send the version of the NodeSDK and authzcache docker image you are using? πŸ™ They should be: NodeSDK version:
2.2.0
authzcache Digest:
sha256:e9746c784721a7560f164c386ea921adfe47a2c01400c0778b5cbf9fc80bc4e0
(docker pull descope/authzcache:latest)
πŸ‘ 1
k
I am not able to verify that @Yosi Haran...will defer to @Mike Hudson and @Vivek Sharma
v
@Yosi Haran For authzcache, we're already on the latest version. For the Node SDK, I’ll update to the latest version, test again, and then confirm whether the FGA cache is working as expected.
y
Thanks @Vivek Sharma, the NodeSDK update is the more critical now for the latency issue, so hopefully the update will help, waiting to see your results πŸ™
v
@Yosi Haran No luck, it still doesn't work. Please find the attached logs and let me know if anything is required
y
Checking now, will update soon πŸ‘€ πŸ™ Can you just please add a bit more context as to what exactly is failing now? If you can point out a single request that took too long, that would be the most helpful, but I'll start looking anyway πŸ™
v
@Yosi Haran We are setting up the Descope client using the FGA cache URL and consuming it within an API. However, the request is timing out, and we are receiving a 504 Gateway Timeout error. Observed Behavior: β€’ When the FGA cache URL is configured, the API request times out and returns a 504 Gateway Timeout. β€’ When the FGA cache URL is not configured, the API works as expected. Context: We are trying to fetch a list of items, where we are checking the corresponding FGA relations as part of the authorization flow.
y
Summarizing here just for visibility: @Vivek Sharma showed me the issue over a productize zoom meeting, and we reviewed the Descope SDK integration as well, which was correctly done πŸ‘ The error being returned is a CORS error, which is possibly something we can solve in the FGA Cache middleware layer, I am now looking into it Thanks again for the feedback and clear explanations, I hope to be able to update soon πŸ™
πŸ‘ 1
@Vivek Sharma or can you please share (or tag Harsh to share) the actual value of the FGA cache URL you are using in the SDK? Also, do you have any other services calling authzcache? I'm afraid that the CORS issue is a red herring related to the gateway timeout response. Perhaps the issue is that the specific requests sent from the client we looked at together are not reaching the authzcache, due to some issue with the FGA Cache URL being used in that specific service, and the logs we are seeing there are from other usages in the code?
Another data point which points to request likely not reaching authzcache is that the default timeout there is 10 seconds, so a failure would have been returned sooner if the requests were reaching it
v
@Harsh Gajjar
h
@Yosi Haran This is FGA cache URL we are using http://dev-authzcache-service.default.svc.cluster.local. Our k8s cluster IP service is listening on 80 and it's forwarding request to container on 8189 cc: @Vivek Sharma
v
@Yosi Haran None of the services are calling Authz Cache apart from the one on which we are trying to test authz cache changes
y
Thanks guys, this is very helpful, I will dig deeper on Sunday
πŸ‘ 1
Good morning/afternoon everyone, just updating that I'm not sure yet but might have an angle with the node-sdk, will have a fix ready for testing shortly. Thank you again for your patience and clear cooperation with this issue, it's very much appreciated πŸ™
v
Thanks for the update @Yosi Haran
πŸ™ 1
y
@Vivek Sharma I have released the fix, can you please upgrade Descope Node SDK to version
2.2.1
and try to use fgaCacheUrl again? πŸ™
v
@Yosi Haran Yes. I will update you shortly on this
πŸ™ 1
@Yosi Haran Good news, its working. Next, I need to compare response times with and without fga cache for 1000+ records. cc - @Mike Hudson @Kenneth Knoll
πŸ™Œ 1
πŸŽ‰ 3
πŸ™†β€β™‚οΈ 1
πŸ™ 1
k
@Vivek Sharma thanks for picking up with this and helping to troubleshoot and thanks @Yosi Haran and @Eliya Sadan for the effort to help resolve. Seems the Aptly team keeps pushing the FGA boundaries! 😎 πŸ’ͺ
πŸ‘ 1
πŸ™Œ 1
y
Hello @Vivek Sharma, this is not urgent or critical, but we've also released a fix for the bug in the authzcache that prevented us from collecting aggregated analytics for debugging. This means that updating the docker image will now help us assist quicker with any future issues you might encounter πŸ™
πŸ‘ 1
(and as described in the dockerhub link, you may also opt-out of this by adjusting the env variables, although only aggregated performance statistics are collected without any PII of course)
v
Thanks for the update @Yosi Haran
h
@Yosi Haran The latest image from authzcache doesn't seem to have arm support. can you please check with team as the service is stuck in pending state.
y
Thank you @Harsh Gajjar, I will take this with our platform team at top priority
πŸ‘ 2
@Harsh Gajjar we fixed the build issue and released a new version which should work on both arm and amd, can you please pull the latest image again and let me know if the issue was resolved? πŸ™
πŸ™Œ 1
h
Thanks @Yosi Haran for quick response and update, it is running now. This is the image id : docker.io/descope/authzcache@sha256:b3f0bda78d471a25688b8773d18ec0ca68d75d5458e3b44947d8c2a47690f6f4
πŸ™ 1
v
Hi @Yosi Haran, We tested the FGA cache changes and observed a marginal latency improvement of ~400–500 ms. Additionally, for permission checks: β€’ The Descope API takes ~350 ms for a single permission check β€’ When checking multiple permissions (e.g., 5), the total time increases to ~3500 ms I’ve attached logs for both with and without the authz cache. You can search for "Descope API call" in the logs to review the API timings. I’ve also included a document with FGA relation checks and the permissions object for further debugging. If you need any additional information or would like to jump on a working session to expedite this, please feel free to drop me a direct message. cc @Mike Hudson @Kenneth Knoll @Reshma @Shreyansh Sheth
y
Hi @Vivek Sharma , thank you very much for this valuable feedback! It's the weekend where I'm based so I am AFK for the day, but will review the data on Sunday and will keep you posted πŸ™
πŸ‘ 1
@Eliya Sadan FYI β˜οΈπŸ™
Hey @Vivek Sharma, I analyzed the logs and collected the aggregated metrics from our end. I want to be sure I'm looking at the correct time window, since I'm seeing numbers that are a bit different, but could be because of a simple time window difference. I think we can already see that cache hits reduce the waiting time to 1ms at most, which is good, but perhaps we can further optimize our backend performance for the bulk-check use case... I'd just like to make sure my understanding is correct, so please let me know when would be a good time for a short 15 min zoom and I'll be more than happy to send an invite πŸ™
v
Yes @Yosi Haran, Lets get on a zoom call. Either 11:30 AM IST works or by any chance we miss that window then I am available anytime after 4:00 PM IST
y
@Vivek Sharma 11:30 AM IST works great, I've sent a calendar invite πŸ™
πŸ‘ 1
v
Hey @Yosi Haran The time in the logs are in UTC. The attached file contains the code snippet which shows how we are checking for permission in descope. In case, you require any other information from my end please feel free to reach out at any part of the day. I will try to respond as soon as possible. Thanks for the support πŸ˜ƒ
y
Thank you again @Vivek Sharma, I am looking into it and will keep you posted πŸ™
@Vivek Sharma one more question, to confirm: can you please share the descope projectId that you were using for these tests? πŸ™
r
@Yosi Haran @Vivek Sharma just stepped out for some work. So sending the projectId on his behalf. CC @Shreyansh Sheth P2mDFvFZYGZ4pt1KzQVgaF89Dmr9
πŸ™ 1
v
@Yosi Haran Any findings?
y
Hey @Vivek Sharma, we did find potential for better handling of concurrent checks in our backend which I'm hopeful will produce much better results for your use case. I'll let you know once we manage to deploy it, I'm trying to expedite it specifically so that you can run the performance test again, I will let you know as soon as it's ready.
πŸ‘ 1
v
Thanks for the update @Yosi Haran
y
Hey @Vivek Sharma, good evening, I'm planning to deploy the fix tomorrow, will let you know once it's live πŸ™
🀞 1
πŸ™Œ 1
Hi @Vivek Sharma, good morning, the performance fix is live, feel free to re-run the test when ready If you can also share the updated results I'd really appreciate it, and as always please feel free to keep me posted and lmk if there are any other issues πŸ™
v
@Yosi Haran Just confirming that we need to update only Authz Cache container and descope sdk remains as it is?
y
No need to update anything on your end, the change was done in our backend
πŸ™Œ 1
v
@Yosi Haran No improvements. Its still the same.
y
This is surprising, we saw significant improvements internally... please let me double check the deploy with our system team, will update shortly πŸ™
πŸ‘ 1
@Vivek Sharma the deploy looks good, but I'm having trouble finding calls from your projectID in our backend, I see 0 calls for
P2mDFvFZYGZ4pt1KzQVgaF89Dmr9
πŸ€” Could you please re-confirm and let me know which projectId you used? πŸ™
v
Project ID: P2mDFvFZYGZ4pt1KzQVgaF89Dmr9
y
Thanks, I'm checking, will update soon πŸ™
I managed to find the relevant data. The query that best matches the long running query below arrived and completed within
4ms
. Additionally, the cache metrics do not show any long running queries that match the
~8s
delay we are seeing in the logs below... However, I see that only 16 tuples were checked in the backend, and 80 were requested from the cache. So I will dig into the cache logic to make sure we do not have any potential issue there either, and will update more soon. @Vivek Sharma From your end, can you please verify that
setupDescopeClient()
does not cause any locking or waiting for other requests to finish? Seems unlikely, but I don't know what this method does, so worth verifying as well if that's ok πŸ™
Copy code
public async checkRelationFGA(relations: IFGARelation[]): Promise<IFGACheckMap[]> {
    await this.setupDescopeClient();  // <-- THIS
    const response = await this.descopeClient.management.fga.check(relations);
    return response.data ?? [];
}
Copy code
{"timestamp":"2026-04-16T09:01:50.130Z","status":"debug","level":"debug","message":"[checkPermissions] Calling Descope checkRelationFGA API","service":"Actions service","env":"development","logger.name":"ActionService"}
{"timestamp":"2026-04-16T09:01:58.744Z","status":"debug","level":"debug","message":"[getGlobalSearchActionList] transformActionToResponseDto branch completed in 8613ms","service":"Actions service","env":"development","logger.name":"ActionService"}
{"timestamp":"2026-04-16T09:01:58.874Z","status":"debug","level":"debug","message":"[checkPermissions] Descope checkRelationFGA API completed in 8744ms (response size: 80 checks)","service":"Actions service","env":"development","logger.name":"ActionService"}
v
@Yosi Haran This appears to be a non-blocking piece of code. From the logs, the Descope API is invoked three times, and in the first two calls it validates the view permission, each returning within ~300ms. If you suspect any other part of the implementation that could contribute to this issue, please highlight it. That will help us narrow down the possible causes more effectively.
πŸ‘ 1
y
I couldn't find (at least, not yet πŸ˜… ) any additional explanation for the 8 second delay. All layers (backend/cache/sdk) seem to be working correctly and avoiding redundant locks, and reported analytics support this and logs suggest good performance... Perhaps the timing code used in the test is also wrapping local DB actions? I'll also be happy to look at it myself, if you can share your benchmarking code? πŸ™
v
We are currently using the built-in Date functions to capture the start time and calculate the total execution time once the function call completes. I can share specific functions that include this benchmarking logic, along with the areas where we are observing higher latency, to help with further analysis. Also let me know in case you need to review anything we can get on a call to expedite the things.
If you see permissionBranchPromise here it calls a checkPermissions function which do not include any local DB calls. It just creates relations and then check those in Descope
πŸ™ 1
y
@Vivek Sharma I'm not sure since I am not familiar enough with the benchmarking code, but could you please review this feedback from Claude? According to my understanding it's saying that the node worker that is waiting for the FGA response is getting blocked by other actions which causes this delay. Does this make sense? (it could likely be wrong, it's just an LLM analysis πŸ™)
v
@Yosi Haran From our end, we can isolate this by invoking the same function independently, outside of the main execution flow, with the same action items. This should help us validate whether the issue is within the function itself or influenced by surrounding logic. I’ll share my observations once the changes are in place.
πŸ™Œ 1
y
Awesome, that would be great, I'll wait for the results πŸ™
v
Hi @Yosi Haran, I’ve verified the changes, and everything on the Descope side looks good. I’m now consistently getting responses from the Descope API under 200ms. Thanks for your support on this. I’ll now focus on reducing the remaining latency on our end.
πŸ™Œ 2
y
That's great to hear, thanks again for the feedback, and please let me know if anything else comes up πŸ™
πŸ‘ 1
gratitude thank you 1
v
Sure @Yosi Haran πŸ™‚