12

What is the maximum estimated time before execution of an @future annotated method starts, after the call to the function is made? Is this in the order of seconds? Or can it take up to minutes before the method is started? Are there any guidelines for this?

update; after reading Shailesh Deshpande's answer, I'm getting to a more discussion prone level: we have been telling some customers that we're the system responds in real-time. Do we need to notifiy them about this possible "not-real-time"-part of the system, or would you say that an Apex-based system that uses @future can still be sold as being real-time?

I'm not sure if this is a correct place for this question, feel free to close this if you don't think it fits here.

4 Answers 4

15

There is an official explanation from Salesforce,

Asynchronous Processing in Force.com http://www.salesforce.com/us/developer/docs/async_processing/salesforce_async_processing.pdf

1
  • 4
    Great doc that explains more than most people would want to know about async jobs! TL;DR: if you have under 12 future jobs in the queue, they should execute near-immediately; if you exceed 12 concurrent future jobs, the ones in the back of the queue get delayed for at least 5 minutes.
    – jkraybill
    Commented Jan 22, 2013 at 3:39
6

There are no guarantees, like @Shailesh Deshpande stated.

This Advanced Asynchronous Apex DF 12 session has a good high level overview of how some of the processing prioritization is done.

The lag time can depend on the volume of executions in other orgs in the multi-tenant environment. Salesforce allocates more threads for synchronous processing since that is by far their main use case (e.g., actual SF users). Also, there is a lookahead algorithm for the queue that will move some of your org's jobs to the back of the queue if your jobs occupy more than a certain percentage (e.g., 60%) of the first X jobs in queue. This is to prevent a single org from monopolizing all asynch processing.

I have never had any issues with @future methods not executing almost immediately.

4

The time is not gauranteed. It usually executes immediately in few seconds, however, as they are executed asynchronously, the time is not gauranteed. Also, remember that any method using the future annotation requires special consideration because the method does not necessarily execute in the same order it is called

0
3

We intermittently experience delays of over an hour on @future calls. This delay is independent of the number of calls submitted. We opened a ticket and were told that there is no SLA on asynchronus future calls.

You must log in to answer this question.

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