Submit More Batch Jobs with Apex Flex Queue (Generally Available)

Submit up to 100 batch jobs simultaneously and actively manage the order of the queued jobs to control which batch jobs are processed first. This enhancement provides you more flexibility in managing your batch jobs.


For all new organizations in Spring ’15, Apex Flex Queue is enabled by default. To enable Apex Flex Queue in an existing organization, activate the Apex Flex Queue critical update in Setup.

This update doesn’t change the way you submit batch jobs but enables you to submit more batch jobs than before. This update doesn’t affect the existing behavior of processing batch jobs after they’re queued. The Holding status has been added for batch jobs, which might affect queries against AsyncApexJob.

See “Critical Updates Overview” in the Salesforce Help for more details about critical updates.

Previously, you could submit only up to five batch jobs simultaneously. The Apex flex queue enables you to submit up to 100 additional batch jobs for execution. Any jobs that are submitted for execution are in holding status and are placed in the Apex flex queue. Up to 100 batch jobs can be in the holding status. When system resources become available, the system picks up jobs from the top of the Apex flex queue and moves them to the batch job queue. The system can process up to five queued or active jobs simultaneously. The status of these moved jobs changes from Holding to Queued. Queued jobs get executed when the system is ready to process new jobs.

Administrators can modify the order of jobs that are held in the Apex flex queue to control when they get processed by the system. For example, administrators can move a batch job up to the first position in the holding queue so that it’s the first job that gets processed when the system fetches the next held job from the flex queue. Without administrator intervention, jobs are processed first-in first-out—in the order in which they’re submitted. To monitor and reorder held batch jobs in the Salesforce user interface, from Setup click Jobs | Apex Flex Queue.

Submitting Jobs by Calling Database.executeBatch

When you submit batch jobs by calling Database.executeBatch, the system places your batch job in Holding status before processing the job.

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.

When system resources become available, the system picks up the next job from the top of the flex queue for processing and changes its status to Queued.

New AsyncApexJob Status Field Value

The AsyncApexJob object, which represents a batch job, has a new Status field value of Holding. This new status indicates that the job is placed in the flex queue and is waiting to be processed when system resources become available.