hi, i turned on `proxyFactsViaPdp` when i call the...
# permit-saas
t
hi, i turned on
proxyFactsViaPdp
when i call the permit client, because i have multiple operations that i call from permit. but it made my API slow. is there any way to speed it up?
a
Hi @Tamara, I'm an AI assistant for Permit.io. I'll analyze available sources and get back to you shortly.
* Yes, the slowdown is expected when
proxyFactsViaPdp
is enabled because API requests wait for data synchronization before returning. (1) Here are a few ways to improve performance: 1. Use
waitForSync
only when needed
Instead of enabling
proxyFactsViaPdp
globally, you can selectively wait for sync only on specific operations where you need immediate consistency. This way, other operations won't incur the wait time. ​*Node.js example:*​
Copy code
// Only wait for sync on this specific operation
const user = await permit.api.users.waitForSync(15) .create({ /* user data */ }) ;
, (2) ​*Go example:*​
Copy code
// Override the default timeout for a specific operation
user, _ := permit.Api.Users.WaitForSync(15) .CreateUser(ctx, *newUser)
(1) , (3) 2. Configure a shorter timeout You can set a timeout so requests don't wait indefinitely. Use
factsSyncTimeout
to limit how long the SDK waits for synchronization: ​*Node.js:*​
Copy code
const permit = new Permit({
  token: "<your-api-key>",
  pdp: "<http://localhost:7766>",
  proxyFactsViaPdp: true,
  factsSyncTimeout: 10, // Wait up to 10 seconds
  factsSyncTimeoutPolicy: "ignore" // Continue if timeout is reached
}) ;
(1) , (4) 3. Use
timeout: 0
for no waiting
Setting timeout to
0
means no waiting—the request responds immediately without waiting for sync. (1) 4. Deployment considerations Deploy your PDP as a ​*Centralized PDP*​ or ​*Sidecar*​ to your application. This ensures the same PDP instance handles both data creation and permission checks, which improves sync times. Using a PDP Cluster with load balancing is less optimal because permission checks may be routed to PDPs that haven't received the data update yet. *
t
what does "Deploy your PDP as a Centralized PDP or Sidecar to your application" mean?
o
@Ask Inkeep
a
Thanks for tagging me @Or Weis. I'll look through relevant sources and get back to you shortly.
* These are two different PDP deployment patterns: ​*Sidecar PDP*​ A sidecar means deploying a PDP container alongside each of your application services. The PDP runs in the same pod/host as your service, so authorization queries stay local with minimal latency. (1)
Copy code
Your Network

query → PDP Sidecar → Your service
                ↓
        <http://Permit.io|Permit.io> Cloud
​*Centralized PDP*​ A centralized PDP is a single PDP instance that handles authorization queries from multiple services. It's simpler to set up and manage, but as the number of services grows, it can become a bottleneck.
Copy code
Your Network

Service #1 → query →
                      PDP → <http://Permit.io|Permit.io> Cloud
Service #2 → query →
​*Why this matters for `proxyFactsViaPdp`:*​ When using
proxyFactsViaPdp
, you want the ​_same_​ PDP instance to handle both data creation and permission checks. With a sidecar or centralized PDP, this is guaranteed. (2) If you use a ​_PDP Cluster_​ with load balancing, permission checks may be routed to a different PDP that hasn't received the data update yet—which defeats the purpose of waiting for sync.
To learn more, see the sources I considered: [[1] Permit's PDP (Policy Decision Point)](https://docs.permit.io/concepts/pdp/overview) [[2] Send Consistent Updates (Read-Your-Own-Writes)](https://docs.permit.io/how-to/manage-data/local-facts-uploader)