Batch vs Queueable vs Future vs Scheduled Apex: Choosing Async Apex
Most async Apex bugs aren't logic bugs. They're picking the wrong tool: a future method that blows up the moment a batch job touches the same object, a scheduled class that tries a callout and fails, or a batch job launched from a trigger that fills the flex queue during a data load.
Salesforce gives you four ways to run Apex later: future methods, Queueable, Batch and Scheduled Apex. In this post you'll describe a real workload and watch each option pass or fail, size a batch job against your org's daily async allowance, then test yourself on the scenarios that trip people up in code reviews and interviews.
The Async Picker
Describe your workload. All four options update as you change it, with the rule behind each verdict.
1. Future methods: simple, but now legacy
A method annotated with @future runs in its own thread when resources are free. It must be static, return void, and take only primitives, or arrays and collections of primitives. No sObjects: the record could change between the call and the run, so you pass IDs and query again. Add callout=true to make callouts.
public with sharing class AccountSync {
@future(callout=true)
public static void pushToErp(Set<Id> accountIds) {
// Re-query: the records may have changed since the call
List<Account> accts = [SELECT Id, Name FROM Account WHERE Id IN :accountIds WITH USER_MODE];
// ...build the request and call the ERP through a Named Credential
}
}The Apex Developer Guide now says it plainly: Salesforce recommends Queueable Apex instead of future methods. You get no job ID back, you can't chain, and the governor limits allow zero future calls in batch and future contexts. That last rule is what breaks orgs: a trigger that calls a future method works fine from the UI, then throws the first time a batch job updates the same object.
2. Queueable: the default choice
Queueable Apex covers everything a future method does, plus three things you'll want sooner or later. System.enqueueJob returns an AsyncApexJob ID you can monitor. The class can hold sObjects and custom types as member variables. And a running job can enqueue the next one, which is how you build retries and multi-step processes.
public with sharing class ErpSyncJob implements Queueable, Database.AllowsCallouts {
private final List<Account> accounts;
public ErpSyncJob(List<Account> accounts) { this.accounts = accounts; }
public void execute(QueueableContext ctx) {
HttpRequest req = new HttpRequest();
req.setEndpoint('callout:ERP/accounts');
req.setMethod('POST');
req.setBody(JSON.serialize(accounts));
HttpResponse res = new Http().send(req);
// Retry by chaining: one child job per execution
if (res.getStatusCode() != 200 && AsyncInfo.getCurrentQueueableStackDepth() < AsyncInfo.getMaximumQueueableStackDepth()) {
System.enqueueJob(new ErpSyncJob(accounts));
}
}
}
// Caller: cap the retry chain at 4 jobs
AsyncOptions opts = new AsyncOptions();
opts.MaximumQueueableStackDepth = 4;
Id jobId = System.enqueueJob(new ErpSyncJob(accts), opts);
The rules worth memorising: up to 50 jobs per synchronous transaction, but only 1 from an asynchronous one. Each running job can start one child. Callouts need the Database.AllowsCallouts marker interface. You can delay a job by 0 to 10 minutes, cap chain depth with AsyncOptions, reject duplicates by signature, and attach a Transaction Finalizer to recover when a job fails. In Developer and Trial orgs, chains stop at a default depth of five.
3. Batch Apex: for data that won't fit in one transaction
Batch Apex splits a dataset into chunks. start() defines the records (a QueryLocator can return up to 50 million), execute() runs once per chunk, and finish() runs at the end. Every chunk is its own transaction with fresh governor limits, which is the whole point, and also the catch: if chunk 3 fails, chunks 1 and 2 stay committed.
public with sharing class CloseStaleCases implements Database.Batchable<SObject>, Database.Stateful {
private Integer closed = 0; // survives between chunks thanks to Database.Stateful
public Database.QueryLocator start(Database.BatchableContext bc) {
return Database.getQueryLocator([
SELECT Id, Status FROM Case
WHERE Status = 'Waiting' AND LastModifiedDate < LAST_N_DAYS:90
]);
}
public void execute(Database.BatchableContext bc, List<Case> scope) {
for (Case c : scope) { c.Status = 'Closed'; }
update scope;
closed += scope.size();
}
public void finish(Database.BatchableContext bc) {
System.debug('Closed ' + closed + ' cases');
// Chain the next job here (API 26.0+), never from execute()
}
}
Id batchId = Database.executeBatch(new CloseStaleCases(), 200);
Only five batch jobs can be queued or active at once per org. Extra jobs wait in the Apex flex queue with a Holding status, and it holds 100. Without a scope, chunks are 200 records; with a QueryLocator the maximum is 2,000. Future methods aren't allowed in a batch class at all. And Trailhead's own advice is blunt: if your data fits in one batch, use Queueable instead.
4. Scheduled Apex: the clock, not the worker
A class that implements Schedulable runs on a cron expression set with System.schedule or the Schedule Apex page. Think of it as the alarm that starts the real work. The Apex Scheduler docs recommend keeping execute() thin and handing off to another class.
public with sharing class NightlyCaseCleanup implements Schedulable {
public void execute(SchedulableContext ctx) {
Database.executeBatch(new CloseStaleCases(), 200);
}
}
// Seconds Minutes Hours Day_of_month Month Day_of_week: every day at 02:00
String cronId = System.schedule('Nightly case cleanup', '0 0 2 * * ?', new NightlyCaseCleanup());
Three things catch people out. Scheduled Apex is async, but synchronous governor limits apply. Synchronous callouts aren't supported, so call out from a Queueable or a batch class that implements Database.AllowsCallouts. And an org can hold 100 scheduled jobs (5 in Developer Edition). For a one-off future run of a batch, System.scheduleBatch skips the Schedulable wrapper.
Batch Sizing Planner
Enter your record count and scope size. See how many chunks you'll run and how much of the shared daily async allowance they take.
Estimate only. The allowance is the greater of 250,000 or licenses × 200 and is shared by every future, Queueable, batch and scheduled execution in the org, so leave headroom for everything else that runs.
5. One allowance, shared by all four
Every async execution draws from one 24-hour org allowance: 250,000, or user licenses × 200, whichever is greater. A chatty trigger that enqueues a job per record and a nightly batch with tiny chunks compete for the same pool. You can watch usage on the Apex Jobs and All Scheduled Jobs pages in Setup, or read DailyAsyncApexExecutions from System.OrgLimits.
Async transactions do get more room per run: 200 SOQL queries instead of 100, and 60 seconds of CPU instead of 10. The current Apex Developer Guide lists heap at 10 MB synchronous and 25 MB asynchronous; older versions of the guide list 6 MB and 12 MB, so check which numbers your org's release enforces before you lean on them.
6. What's changed recently
Two release changes matter for this decision. First, Apex Cursors with chained Queueables are now documented as an alternative to Batch Apex. A cursor can point at up to 50 million rows, and a Queueable chain doesn't take one of the five batch slots or wait in the flex queue. The trade-off is that you write the sequencing and retry logic yourself, while Batch gives you that structure plus per-chunk error isolation. Salesforce's cursors versus batch guide walks through when each wins.
Second, Summer '26 introduced elastic limits for async jobs as a beta: Queueable and future jobs over the daily limit are throttled rather than rejected, up to twice the licensed amount. Treat it as a safety net, not capacity planning, and confirm it's enabled before you count on it.
Database.executeBatch throws a LimitException. Enqueue one Queueable per transaction instead, or flag records and let a scheduled batch sweep them up.
Predict the Outcome
Six scenarios that come up in real orgs and real interviews.
Cheat sheet: side by side
| Future | Queueable | Batch | Scheduled | |
|---|---|---|---|---|
| Starts | When resources are free | When resources are free, or after a 0–10 min delay | When one of 5 slots frees up | On a cron schedule (at most hourly) |
| Parameters | Primitives only | Any type, incl. sObjects | Any type via constructor | Any type via constructor |
| Job ID | No | Yes (AsyncApexJob) | Yes (AsyncApexJob) | Yes (CronTrigger) |
| Chaining | No | One child per job | From finish() | Starts other jobs |
| Callouts | callout=true | Database.AllowsCallouts | Database.AllowsCallouts | Not directly; hand off |
| Limits | Async | Async | Async, reset per chunk | Synchronous |
| Key cap | 50 per sync txn; 0 from batch/future | 50 per sync txn; 1 from async | 5 active, 100 in flex queue | 100 scheduled jobs |
| Best for | Existing code; migrate it | Callouts, follow-up work, retries | Large-volume data jobs | Nightly and weekly runs |
Checked against the Apex Developer Guide (Winter '27 docs) and the Asynchronous Apex Trailhead module in November 2026. Limits change between releases, so confirm current values in Execution Governors and Limits.
Official Resources
Straight from Salesforce: the docs this article is based on.
Trailhead
Developer Docs
Async jobs piling up or failing in your org?
Book a session with our architects to review your async design, limits and job monitoring.
All information in this article was collected from publicly available resources, including official Salesforce documentation.