Skip to main content

SF-0386 · Concept · Medium

What is the apex flex queue?

✓ Verified by Vikas Singhal · Last reviewed 5/17/2026 · Updated for Spring '26

The Apex Flex Queue is a holding area for Batch jobs that have been submitted but cannot yet enter the active queue. Salesforce limits each org to 5 simultaneously running Batch jobs (Queued or Processing status); jobs submitted while those slots are full sit in the Flex Queue with status Holding until a slot frees up. You can hold up to 100 jobs in the Flex Queue at one time.

The two queues in the lifecycle

Database.executeBatch(...)


   Apex Flex Queue       ← up to 100 jobs in "Holding" status

        ▼ (when a slot opens)
   Active Queue          ← up to 5 jobs in "Queued" or "Processing" status


   Job runs (start → executes → finish)

When you call Database.executeBatch, the platform first checks whether the active queue has room. If yes, the job moves straight to Queued. If no, it lands in Holding in the Flex Queue.

Why it exists

Before the Flex Queue, hitting the 5-job ceiling would throw an error on Database.executeBatch — submitters had to retry. The Flex Queue absorbs that pressure: you can submit work all day and Salesforce drains it as capacity allows. The 100-job buffer is large enough that most orgs never hit the wall.

Where you see it

Setup → Apex Flex Queue lists Holding jobs with status, submitter, and submitted timestamp. You can also query directly:

List<AsyncApexJob> holding = [
    SELECT Id, ApexClass.Name, Status, CreatedDate
    FROM AsyncApexJob
    WHERE JobType = 'BatchApex' AND Status = 'Holding'
    ORDER BY CreatedDate
];

Reordering and aborting

You can change the order of jobs in the Flex Queue while they’re in Holding. Once a job moves to Queued or Processing, the order is fixed.

Reorder via the Setup UI (drag and drop) or programmatically:

Boolean ok = FlexQueue.moveJobToFront(holdingJobId);
// also: moveJobToEnd, moveAfterJob, moveBeforeJob

To remove a job from Holding before it starts:

System.abortJob(holdingJobId);

The two relevant limits

LimitValue
Max active Batch jobs (Queued + Processing)5
Max jobs in Flex Queue (Holding)100
What happens when you submit job #106?LimitException: Flex Queue full

What kinds of jobs use it

The Flex Queue holds Batch jobs only. It doesn’t apply to:

  • Queueable jobs (they have their own queue, limit of 50 enqueued per transaction)
  • @future calls (their own queue, 250,000/day org limit)
  • Scheduled Apex (the scheduler has its own slots — 100 max)

Common interview follow-ups

  • What’s the maximum size of the Apex Flex Queue? — 100 jobs in Holding.
  • Can I reorder a job once it’s running? — No, only while it’s in Holding.
  • What happens when I exceed 100?Database.executeBatch throws and the job isn’t queued. Catch the exception in the submitter and retry later.
  • How is the Flex Queue different from the active queue? — Active queue holds Queued/Processing jobs (max 5). Flex Queue holds Holding jobs (max 100) waiting to move into the active queue.

Verified against: Apex Developer Guide — Apex Flex Queue. Last reviewed 2026-05-17.