Apex Flex Queue
The Apex Flex Queue is the Salesforce holding queue for batch Apex jobs that have been submitted but not yet started.
Definition
The Apex Flex Queue is the Salesforce holding queue for batch Apex jobs that have been submitted but not yet started. The platform runs up to five concurrent batch jobs per org; any batch class submitted while five are already running lands in the Flex Queue with a status of Holding. The queue holds up to 100 jobs at a time. Once a running slot opens, Salesforce promotes the next job in the queue to Queued status and the batch class begins execution. Without the Flex Queue, every System.LimitException for too many batch jobs would fail outright; with it, the platform smooths submission spikes into the available execution capacity.
Beyond simple holding, the Flex Queue is a management surface for those waiting jobs. Setup, Apex Flex Queue lets administrators reorder Holding jobs, move a low-priority job to the back, promote an urgent one to the front, or cancel jobs that should not run at all. Reordering is the most-used capability: a long-running daily import suddenly becomes urgent and gets pulled to the top so it does not wait behind a hundred routine nightly maintenance jobs. The queue is per org and applies to every batch Apex job regardless of who submitted it.
How the Apex Flex Queue manages batch concurrency
The five-concurrent-batch limit
Salesforce caps active batch Apex jobs at five per org. The cap exists to keep one tenant's batch workload from monopolising the platform. Synchronous batch submission beyond five would error out without the Flex Queue, so the platform adds new submissions to Holding instead. As soon as one of the five active jobs finishes, the platform pulls the next Holding job into a running slot.
The 100-job queue cap
The Flex Queue itself caps at 100 jobs in Holding status. The 101st submission produces a LimitException. Orgs that hit this cap usually have a job-scheduling problem: a Flow or scheduled class is submitting batch jobs too aggressively. The queue is the wrong tool to grow past 100; right-sizing the submission cadence is the cure.
Job statuses you will see
Batch jobs flow through Holding, Queued, Preparing, Processing, Completed, Failed, or Aborted. Holding is the Flex Queue. Queued means the job has left the Flex Queue and is about to start. Preparing runs the start method. Processing executes the execute method in batches. Completed, Failed, and Aborted are terminal. Monitoring jobs through these statuses lives in Setup, Apex Jobs.
Reordering holding jobs
Setup, Apex Flex Queue exposes a list of Holding jobs with reorder buttons and a cancel option. Drag rows up or down to change priority. The change takes effect immediately, so the next slot pulls the new top job. This is the surface to reach for when a daily import is suddenly an urgent input to a board meeting and must run before three hours of routine cleanup.
Submitting batch jobs with Database.executeBatch
The standard submission path is Database.executeBatch(batchInstance, scopeSize). The method returns the job ID. If the platform has fewer than five active batch jobs running, the new job starts immediately. Otherwise, it lands in Holding inside the Flex Queue. The caller does not need to do anything special; the queue is transparent.
Programmatic queue management
The FlexQueue Apex class provides programmatic control: moveJobToEnd, moveJobToFront, moveBeforeJob, moveAfterJob. Scheduled classes and integration code can reorder Holding jobs without an admin clicking through Setup. This is useful for self-tuning batch pipelines that want to keep high-priority jobs ahead of routine maintenance even at 3 a.m.
Common error patterns
Three errors dominate Flex Queue interactions. Too many queued jobs (100 limit) means the org is submitting batches too aggressively; fix the scheduling pattern, do not increase the limit (you cannot). Job not in queue when reordering means the job already started; reorder only applies to Holding status. Chained batches that submit themselves into a saturated queue can lockstep into starvation; throttle the chain at the submission layer.
Monitoring and alerting
The CronJobDetail and AsyncApexJob objects are the queryable sources of truth. Most production orgs build a dashboard that surfaces holding count, oldest holding age, and recent failures. A Flow that pages on hold counts above 80 catches submission storms before the queue hits 100 and fails the next batch.
How to manage the Apex Flex Queue in production
Most batch jobs flow through the Flex Queue without intervention. Knowing how to reorder, cancel, and monitor it pays off when something urgent shows up at the back of a long queue.
- Open Apex Flex Queue in Setup
Setup, then search for Apex Flex Queue. The page lists every batch job currently in Holding status with submission timestamp and submitter.
- Reorder a holding job
Drag the urgent job to the top of the list, or use the Move to Top button. The change applies immediately; the next running slot will pull the new top job.
- Cancel a holding job
Click Cancel next to any holding job that should not run. Once cancelled the job moves to Aborted status and cannot be resumed.
- Monitor active jobs
Switch to Setup, Apex Jobs. Filter by Status Processing or Queued to see what is currently running and what is about to start.
- Build alerting around hold counts
Schedule a Flow or anonymous Apex to query AsyncApexJob WHERE Status='Holding' and alert when the count exceeds 80. Catching saturation early prevents the 100-job error.
- The five-concurrent and 100-queue limits cannot be raised. Right-size submission patterns; do not try to grow past them.
- Reorder only applies to Holding status. Jobs that already moved to Queued or Processing cannot be moved.
- Chained batches that submit themselves can lockstep the queue if upstream submission is unthrottled. Add explicit pacing at the submission layer.
- Cancelling a holding job does not roll back any work it set up earlier in a chain. Handle compensating logic explicitly.
Trust & references
Cross-checked against the following references.
- Apex Flex QueueApex Developer Guide
- FlexQueue ClassApex Developer Guide
Straight from the source - Salesforce's reference material on Apex Flex Queue.
- Monitor Apex JobsSalesforce Help
Hands-on resources to go deeper on Apex Flex Queue.
About the Author
Dipojjal Chakrabarti is a B2C Solution Architect with 29 Salesforce certifications and over 13 years in the Salesforce ecosystem. He runs salesforcedictionary.com to help admins, developers, architects, and cert/interview candidates sharpen their fundamentals. More about Dipojjal.
Test your knowledge
Q1. What skill set is typically needed to work with Apex Flex Queue?
Q2. Where would a developer typically work with Apex Flex Queue?
Q3. What is a Governor Limit in the context of Apex Flex Queue?
Discussion
Loading discussion…