0

According to documentation.

RUN_TIME : The amount of time that the request took in milliseconds. Requests with a value over five seconds are considered long-running requests for the purposes of the Concurrent Long-Running Apex Limit.

But we also have CPU_TIME which has 10 seconds and 60 seconds timeout depending on Sync and Async transaction.

Question

Say we have 10 concurrent requests running in Apex (SOQL may take more time, but as SOQL is not counted against CPU TIME we should be good), which is still under CPU_TIME limit, and a 11th request comes. Why does SF throws long running concurrent requests exception.

This means technically when the load is heavy the total execution time should be less than 5 seconds, even though CPU time is 10/60 seconds.

1 Answer 1

3

The five second concurrent transaction limit is primarily there to prevent us from consuming too many resources. You can view the 10/60 second limit as a "burst" limit, while the 5 second limit is what we're expected to achieve on average. If your code is constantly running into the concurrent limit issue, you should consider moving some of your processes to asynchronous threads or optimize your code.

3
  • Moving to async may work. But one doubt, if a Async does a DML, then does that transaction of DML gets counted in Long running transaction? Commented May 26, 2022 at 13:57
  • @NagendraSingh The async method itself is a long-running task if it exceeds 5 seconds, even if it performs no DML. The system, however, will only run async code when there's available resources, so in theory, as long as your synchronous code is never over 5 seconds, your asynchronous code will never max out the concurrent limit.
    – sfdcfox
    Commented May 26, 2022 at 14:05
  • Looking at event log where it says IS_LONG_RUNNING_REQUEST as 1, it shows Triggers 95% of the times, now most of our processes are already getting triggered via trigger in async transaction. So I was suspecting as our org fires too many asycn transcation and almost 60% are having execution time more than 5 seconds. I am assuming when asycn apex does a DML the whole DML is taking more than 5 seconds and getting tracked under IS_LONG_RUNNING_REQUEST Commented May 26, 2022 at 15:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .