I have built an application that has 2-way integration with Salesforce using their REST API and Apex Triggers, which send a request to my web service using an HTTP Callout when a custom object is modified.
During development the HTTP Callout happened immediately following the update in Salesforce and as far as I know the same was true in production. However, we are now noticing that sometimes these HTTP Callouts are not immediate, I have measured some situations in which an update has been made in Salesforce and the HTTP request has not been received until 200 seconds later. The average delay seems to be around 10 seconds but it varies wildly between a few seconds and a few minutes.
I cannot find any documentation indicating that HTTP Callouts are not executed immediately. What could the potential cause be for this issue?
I have eliminated my application as a cause of the delayed execution by monitoring the access logs, the time I am measuring is from clicking Save in Salesforce and the request showing up in my access log. All tests pass immediately (with an HTTP Callout mock) which leads me to believe the issue resides within the HTTP Callout functionality.
My suspicion is that perhaps the Salesforce environment we're in is overloaded by other users and our HTTP Callouts are being queued during periods of high load but I am not familiar with the Salesforce architecture so this could be off the mark.