Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

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.

share|improve this question
add comment

4 Answers

up vote 9 down vote accepted

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

share|improve this answer
2  
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 Jan 22 '13 at 3:39
add comment

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.

share|improve this answer
add comment

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

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.