Refer to this link for more info on batch apex: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_batch_interface.htm
1. How many batch jobs can you dispatch before you exceed governor
limits? 100 or 105?
In a single execution, the limit for Database.executeBatch() is 100 with Apex Flex Queue.
With the Apex flex queue, you can submit up to 100 batch jobs.
The outcome of Database.executeBatch is as follows.
The batch job is placed in the Apex flex queue, and its status is set to Holding.
If the Apex flex queue has the maximum number of 100 jobs, Database.executeBatch throws a LimitException and doesn’t add the job
to the queue.
2. Do scheduled jobs and batch jobs sit in the flex queue together? Or do scheduled jobs have their own queue with their own governor limit?
They have separate limits, except for when you schedule a batch job using
All scheduled Apex limits apply for batch jobs scheduled using
System.scheduleBatch. After the batch job is queued (with a status of
Holding or Queued), all batch job limits apply and the job no longer
counts toward scheduled Apex limits.
3. In the case of batch jobs, how exactly would I check whether I'm over the limit or not?
When system resources become available, the system picks up the next
job from the top of the Apex flex queue and moves it to the batch job
queue. The system can process up to five queued or active jobs
simultaneously for each organization. The status of these moved jobs
changes from Holding to Queued. Queued jobs get executed when the
system is ready to process new jobs. You can monitor queued jobs on
the Apex Jobs page.
You can check the current active jobs in apex:
Integer batchJobsActive = [SELECT COUNT() FROM AsyncApexJob WHERE JobType = 'BatchApex' AND Status IN ('Queued', 'Preparing', 'Processing')];
You can check the Flex Queue jobs in apex like this:
Integer batchJobsHolding = [SELECT COUNT() FROM AsyncApexJob WHERE JobType = 'BatchApex' AND Status = 'Holding'];