Skip to main content

Posts

Apex Flex Queue

Explore practical guides and implementation patterns for this topic.

Master Salesforce Scheduled Apex & The Flex Queue
Salesforce Basics

Master Salesforce Scheduled Apex & The Flex Queue

๐Ÿ’ฌ In plain words: Scheduled Apex acts as your org's cron job: "Run this class every night at 2 AM." The Apex Flex Queue is the waiting room for these jobs. Because Salesforce only allows 5 batch jobs to run concurrently, up to 100 additional jobs can sit patiently in the Flex Queue until a slot opens up. You schedule the class, and the platform handles the waiting room. ๐Ÿ“Œ The 2 AM Reminder Example: You need to send subscription renewal reminders daily at 2:00 AM. You write a Schedulable class and set a cron expression: 0 0 2 * * ? . When 2:00 AM hits, what if 9 other heavy batch jobs are already running? No problem. Your reminder job enters the Flex Queue (which holds up to 100 jobs) and waits until one of the 5 active slots becomes available. ๐Ÿง  Memory Aid: The Alarm Clock + The Waiting Room Scheduled Apex is the alarm clock . The Flex Queue is the waiting room (100 seats, 5 doors). Core Concept: How Scheduled Ap...
Topic Apex & Dev
Apex & Dev

Salesforce Apex Flex Queue: Batch Job Management, Limits & Reordering Guide

In plain words: Think of the Apex Flex Queue as a digital waiting room for your batch jobs. Salesforce can run up to 5 batch jobs at the same time. The Flex Queue holds up to 100 additional batch jobs in a Holding status, automatically feeding them into execution as processing slots open up. Managing large-scale data processing in Salesforce requires balancing high data volumes with strict multi-tenant governor limits. While synchronous transactions must complete within milliseconds, Batch Apex handles millions of records asynchronously. The Apex Flex Queue is the core platform infrastructure that governs how these batch jobs are queued, prioritized, and executed without failing due to concurrency constraints. 1. How the Apex Flex Queue Operates Prior to the Flex Queue, submitting a batch job when all processing threads were full resulted in immediate job rejection. The Flex Queue eliminates this limitation by introducing the Holding status: Holdi...