I have tried to find its answer on multiple places but unable to do so, I know Batch classes use Flex queues and Batch queues. Just wondering what does queueable interface or class use? Does it also use flex queues and batch queues or it uses some other queue?


The Flex Queue is its own unique queue, separate from the asynchronous queue. Basically, until a Batchable process starts, it is in the Flex Queue, and can have its priority changed. Once the system has resources, it starts building up jobs to perform in the asynchronous queue. This includes start, execute, and finish methods of Schedulable, Queueable, and Batchable, as well as future methods. I can't find an official Salesforce page with this image, but several blog posts show this depiction of asynchronous processing:

Asynchronous Processing in Salesforce

If anyone can source the appropriate Salesforce page this came from, please feel free to edit this answer.

As you can see, Bulk API, Batch, future (etc) all are in a per-org queue, and they are interleaved. There's a special rule that says that if there are more than 12 asynchronous calls from a single org, another org will get a chance to execute[citation needed]. It appears this may have changed, as the current documentation for @future says:

Avoid adding large numbers of future methods to the asynchronous queue, if possible. If more than 2,000 unprocessed requests from a single organization are in the queue, any additional requests from the same organization will be delayed while the queue handles requests from other organizations.

There's no such thing as different queues for different types of processes. Salesforce considers each of these asynchronous calls equally, with some minor caveats (namely, one one Batchable start method may execute at a time per org). Generally speaking, asynchronous calls are processed in the order they are received, but if an org has too many items in the asynchronous queue, the queue may be reordered. Also, chaining requests (e.g. Queueable calling Queueable) will impose a minimum delay between executions to give other orgs a chance to execute.

| improve this answer | |
  • Thank you so much for the help. So if I got that right the concept of flex queue comes only in case of batch class for the pending/on hold jobs and once the jobs are ready to be processed, they go in asynchronous queue. On the other hand, Queueable and future Method job always go to Asynchronous queue, there is no intermediate queue for them, where the pending jobs are stored? – Student Aug 21 '19 at 18:34

As per my experience the flex queue is the place where all the queued job stay. It keeps there till the time of any free resource found . Also the job queue can hold 100 after that count all the jobs send for the flex queue.

| improve this answer | |
  • ok that's the contradictory information, I am a bit confused now. Do you have any article that you could share? – Student Aug 21 '19 at 19:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.