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
BroncoBoyBroncoBoy 

2 Quick Questions RE: Governor Limit Max # of Asynchronous Apex Method Executions

(https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_gov_limits.htm)
"The maximum number of asynchronous Apex method executions (batch Apex, future methods, Queueable Apex, and scheduled Apex) per a 24-hour period: 250,000 or the number of user licenses in your organization multiplied by 200, whichever is greater"

When we're talking about batch Apex, for example, are we just talking about start(), execute(), finish() methods being applied to that limit or are all methods - even custom methods - also included in that figure as well?

Also is there a way to see how close we are getting to that limit every day?  I looked at the Limits class but didn't see any direct methods there.  We have a couple of huge batch classes that run once a week and I want to make sure we're not getting too close to that limit.
Best Answer chosen by BroncoBoy
V V Satyanarayana MaddipatiV V Satyanarayana Maddipati
Hi

For Batch class, the limit of asynchronous Apex method will depend on the number of batches, the batch class is executed.

Eg: When a batch class is executed, in turn it generates the  batches based on the batch size specified. If your batch class generates 10 batches, the number of asynchronous Apex method executed will be considered as 10.

To view the limits of asynchronous Apex methods for your Org, you can log in to https://workbench.developerforce.com/ by providing your org credentials.
And execute the endpoint /services/data/v37.0/limits  . Once it is executed, you can see the limit in DailyAsyncApexExecutions folder . Below is the sample snapshot:
User-added image

Thanks
Satya.

All Answers

V V Satyanarayana MaddipatiV V Satyanarayana Maddipati
Hi

For Batch class, the limit of asynchronous Apex method will depend on the number of batches, the batch class is executed.

Eg: When a batch class is executed, in turn it generates the  batches based on the batch size specified. If your batch class generates 10 batches, the number of asynchronous Apex method executed will be considered as 10.

To view the limits of asynchronous Apex methods for your Org, you can log in to https://workbench.developerforce.com/ by providing your org credentials.
And execute the endpoint /services/data/v37.0/limits  . Once it is executed, you can see the limit in DailyAsyncApexExecutions folder . Below is the sample snapshot:
User-added image

Thanks
Satya.
This was selected as the best answer
BroncoBoyBroncoBoy
Perfect...exactly what I needed - thank you!
Harjeet Singh 13Harjeet Singh 13
Dear BroncoBoy & @Satya,

I don't know hwther this thread is still active or not . But I need a help on close to same requirements on which I am currently working and left with blank.
I want to send an alert notification when overall organisation Async Apex Execution limit reached 70%of total limit(24hrs API Limit). Say if limit is 2500 and if system already exhausted 1750 of daily Async Apex Limit out of 2500 then any alert should be send to few persons notifying that your organisation limit of Async Apex Executions have reached 70% threshold.

I have done few research on the same but didn't get anything concrete. I saw blogs/documentation stating about Limit class and Limit methods but those are having limit method for future but no where I get any thing related to Async Apex Exceution Limits. In Limit Class I saw there are 2 mthods 'getAsyncCalls()' and 'getLimitAsyncCalls()' but both are related reserved for future use.
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_limits.htm#apex_System_limits_getAsyncCalls

Kindly help me.

Any help will be greatly appreciated.

Many thanks in advance

Thanks & Regards,
Harjeet
BroncoBoyBroncoBoy
Hi Harjeet, Can you can query the ApexAsyncJob object, i.e. SELECT COUNT(Id)? FROM ApexAsyncJob WHERE JobType = 'Future' AND CompletedDate = TODAY() AND Status = 'Completed'? JobTypes: Future SharingRecalculation ScheduledApex BatchApex BatchApexWorker TestRequest TestWorker ApexToken Queueable https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_asyncapexjob.htm Thanks, Bronco
Harjeet Singh 13Harjeet Singh 13
Dear Broco,

Thanks fort your response. My question is why I should only put Job Type = Future? Can I use Job Type =  Future && ScheduledApex &&BatchApex && BatchApexWorker&&Queueable. Because Async Apex is made up of future,batch apex,schedulable all right.

My second question is : Ho wcan I create a class or something which checks that when 75% of daily allowed limit of Async Apex Execution limit(250000 DAILY LIMIT RIGHT NOW) reached then an alert notification send to few usres.

Kindly help me.

Any help will be greatly appreciated.

Many thanks in advance

Thanks & Regards,
Harjeet