I am experiencing slowness when calling endpoint <...
# permit-saas
y
I am experiencing slowness when calling endpoint https://api.permit.io/v2/facts/9aa8bcdc454049cd8c1459f6d1215b4f/f5b553a6ef6847779addd901fc44327b/relationship_tuples/bulk for bulk relationship tuple creation. projectId 9aa8bcdc454049cd8c1459f6d1215b4f and environmentId f5b553a6ef6847779addd901fc44327b. even with single operation it takes about 24 seconds. calling single without batch only takes milli seconds. could you please help me with thi.
a
Hi @Yilmaz Alizadeh, I'm an AI assistant for Permit.io. I'll analyze available sources and get back to you shortly.
I understand you're experiencing significant slowness with the bulk relationship tuple creation endpoint. A 24-second response time for even a single operation in bulk mode versus milliseconds for single operations is definitely concerning. Based on the documentation, bulk operations are currently limited to 1000 items per call and are subject to additional rate limits (1) . The bulk relationship tuple creation endpoint format you're using matches what's documented :
Copy code
curl -X POST <https://api.permit.io/v2/facts/{proj_id}/{env_id}/relationship_tuples/bulk>
To help our engineers investigate this performance issue, could you please provide: 1. ​*Which Workspace / Project / Env you are using*​ (you've already provided project ID 9aa8bcdc454049cd8c1459f6d1215b4f and environment ID f5b553a6ef6847779addd901fc44327b) 2. ​*What calls are you performing*​ - please share the exact SDK code or CURL command you're using, including the payload structure 3. ​*Which PDP version you are running*​ (if you have a local PDP deployed) 4. ​*Relevant logs from your PDP*​ (if applicable) and any error messages or response headers from the API Additionally, it would be helpful to know: • The exact payload size and structure you're sending (even with just one operation) • Whether you're experiencing this consistently or intermittently • Your geographic location relative to the API servers This information will help our team identify whether this is a known issue or something specific to your configuration.
To learn more, see the sources I considered: [[1] Perform Bulk Operations](https://docs.permit.io/how-to/bulk-operations)
y
single operation operations [ { subject: 'user-group:0de77254-e8e9-48fa-ba95-e677b02b722c', relation: 'user-group-read', object: 'document_type:23a47bd3-f9d8-4fdd-87f9-2af08c32ff11', tenant: 'c8217bd9-ed07-4898-b455-f9c9eb615977' } ] takes this long.
this is not related to pdp as I am calling cloud api
private async batchedRequests( endpoint: string, method: HTTPMethod, operations: any[] ) { // Split into batches of 1000 operations (API limit) const BATCH_SIZE = 1000; const batches = batchArray(operations, BATCH_SIZE); const promises = batches.map(async batch => { const response = await fetch(endpoint, { method, headers: { Authorization:
Bearer ${this.apiKey}
, 'Content-Type': 'application/json' }, body: JSON.stringify({ operations: batch }) }); if (!response.ok) { const errorText = await response.text(); throw new Error(
Failed to ${method} for endpoint ${endpoint} in bulk: ${response.status} ${response.statusText} - ${errorText}
); } return response.json(); }); console.log('batches', batches); console.log('operations', operations); console.log(
Starting Promise.all for ${batches.length} batch(es) with ${operations.length} total operations
); console.time('Promise.all execution time'); await Promise.all(promises); console.timeEnd('Promise.all execution time'); }
batch requst code
a
Hey @Yilmaz Alizadeh, Thanks for reaching out! can you provide your workspace name, so I can take a look?
y
1. @Alon Boshi thanks for your reply it is Trustflight
a
@Yilmaz Alizadeh Thanks for bringing this up! I’ve noticed that the query is taking longer than expected. I will open a ticket for this issue and keep you informed of any updates.
🙌 1
Hey @Yilmaz Alizadeh, The performance of this request should be faster now. We are continuing to work on enhancing overall performance and will provide an update once additional improvements are made.
y
thanks for your help. I will test it and let you know.