function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Daniel RetaleatoDaniel Retaleato 

How to avoid Spike Arrest Limits when making API calls from APEX

I'm running into a problem where my APEX code is firing too many API calls in the span of 100ms, so simply, is there a way to delay the code from firing for 101ms. 

As I understand there may be a few 'Bad Code' workarounds such as home brew sleep methods and running for loops until certain conditions have been met, but I would rather avoid these for obvoius reasons.

Thanks for any advice!
AbhishekAbhishek (Salesforce Developers) 
Hi Daniel,

Try the suggestions as mentioned in the below blogs,

https://help.sharpspring.com/hc/en-us/articles/115001067268-Understanding-Salesforce-Daily-API-Limits

https://support.geckoboard.com/hc/en-us/articles/216804218-I-ve-hit-my-Salesforce-API-request-limit

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks.
Daniel RetaleatoDaniel Retaleato
Thanks for the reply, but I'm getting the error from an external server, not from Salesforce. My issue is that I'm sending too many API calls in the span of 100ms to a third pary, who have a limit on their end.
AbhishekAbhishek (Salesforce Developers) 
Then can you check with the external server team?
Daniel RetaleatoDaniel Retaleato
Yes, they responded with: "you might create a running clock/timer/gate-keeper to wait 101 ms between each call." but as i understand it, this is not good coding practice on a multi-tenet server.
AbhishekAbhishek (Salesforce Developers) 
Thanks for the response.

But I don't have any more suggestions Daniel.