Apex – HTTP Callout vs. Callout Processing Time and Long-Running Request Limit

apexgovernorlimitshttprequesttimeout

I have a LWC that loads on a frequently accessed lightning page (thousands of times an hour).

It makes a request through synchronous Apex to a legacy webservice where response times are 20 seconds. The rest of the transaction happens within milliseconds.

Concurrent Apex Limits

Considering concurrent Apex request limit is 10 total requests that go over 5 seconds, I would expect many request to denied, but the documentation states:

"HTTP Callout processing time isn't included when calculating the
limit".

Does this mean that the 20 seconds it takes to get a response is not counted against the transaction time?

Or does "HTTP Callout processing time" refer to the backend operation time related to the SF platform making a request and receiving a response, excluding the actual response time from the endpoint.

The timeout can be extended to 120ms. From the documentation:

The default timeout is 10 seconds. A custom timeout can be defined for
each callout. The minimum is 1 millisecond and the maximum is 120,000
milliseconds. See the examples in the next section for how to set
custom timeouts for Web services or HTTP callouts.

Is the upper limit for this so high to accommodate for the low volume use cases where you do not have overlapping long running API callouts?

Concurrent API Limits

Documentation states:

The following table lists the limits for various types of orgs for concurrent inbound requests (calls) with a duration of 20 seconds or longer.

Org Type ||| Limit
Developer Edition and Trial orgs ||| 5
Production orgs and Sandboxes ||| 25

The timeout limit for an API call is 600,000 milliseconds (10
minutes).

I'm confused by the use of "inbound requests" and "calls". Are these calls to the Salesforce REST API from an external client or calls from Salesforce to external endpoints?

Reference

https://developer.salesforce.com/docs/atlas.en-us.salesforce_app_limits_cheatsheet.meta/salesforce_app_limits_cheatsheet/salesforce_app_limits_platform_api.htm

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_callouts_timeouts.htm

Best Answer

You're not reading this wrong: only the Apex execution time counts against the concurrent long-running transaction limit. Even if your service took 115 seconds every time, you'd never run into that particular limit. Note, however, that there is a limit to the number of concurrent callouts per org, so with enough traffic, it would be possible for some callouts to be denied, but not because of the concurrent long-running limit.

You can make up to 20 concurrent callouts to endpoints outside of your Salesforce org’s domain. You can make unlimited concurrent callouts to internal endpoints. --documentation

Related Topic