function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Governor limits: @future looked like it had some redeemability with regard to the scalability issues created by some of its Governor limits when I learned about the @future annotation, until I read the details.  I have a few questions:


1> If I make multiple invocations of a @future method within an Apex request, does each invocation have its own set of governor limits, or do they apply to all the invocations as a sum?  These future invocations are limited to 10 per Apex invocation. 


2> "No more than 200 method calls per license per 24 hours"...  if I understand it correctly, if we have 400 licensed users of, then this permits 80,000 invocations per 24 hours?  Is this a trailing 24 hours, or a midnight to midnight thing?


3> OK, this is where I really struggle with the limits of future:  "The parameters specified must be primitive dataypes, arrays of primitive datatypes, or collections of primitive datatypes" and "Methods with the future

annotation cannot take sObjects or objects as arguments".  This issue here is that the set of data that you want to act on can change given the same where clause.  For instance, if we notify 1600 contacts, I'd like to use a @future to create 1600 entries of this activity.  But, if I have to requery based on the filter for notification, then this could be 1640 contacts by the time this runs, creating a data integrity issue.  On the other hand, if I could pass the SObject that was created anyway containing the contacts, then the data integrity would be intact.  How are other people handling this?





1. Each @future invocation has it's own set of limits. 

2. Yes you can do 8,000 future calls in 24 hrs. It is a mid-night to  might thing. The Org setting for your default time zone might influence this.

3. Based on the use case that you have, I'd suggest that you use Apex Batch. Apex batch can take a query as a parameter and can deal with much larger data sets than @future. However there are limits around the # of batch instances you can run concurrently.