NexBlazers Logo
NexBlazers Learn • Build • Grow
Architecture & Apex

Batch vs Queueable vs Future vs Scheduled Apex: Choosing Async Apex

Written by NexBlazers Architecture Team November 24, 2026 14 min read Interactive

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.

Future
Fire-and-forget, primitives only. Legacy.
Queueable
The default. Job ID, objects, chaining.
Batch
Millions of records, in chunks.
Scheduled
Runs on a clock, starts the others.
Try it

The Async Picker

Describe your workload. All four options update as you change it, with the rule behind each verdict.

Presets:
Recommended pattern

                        

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.

Architecture Note: Async work enqueued in a transaction only runs if that transaction commits. If a validation rule or unhandled exception rolls back the save, the Queueable you enqueued in the trigger is never processed. That's a feature: never call out before the commit and hope. Enqueue, let the commit happen, and let the job read committed data.
Calculator

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.

Scope size passed to executeBatch 200
1200 (default)2,000 (QueryLocator max)2,500
200
Actual chunk size
10,000
execute() transactions
250,000
Daily async allowance
4%
Of allowance per day
Chunks (each square is one transaction)

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.

Architecture Note: Launching batch jobs from triggers is where orgs get hurt. A large data load fires your trigger once per chunk of records, which can mean hundreds of invocations, each trying to start a batch. Five slots plus a 100-job flex queue can't absorb that: once the flex queue is full, Database.executeBatch throws a LimitException. Enqueue one Queueable per transaction instead, or flag records and let a scheduled batch sweep them up.
Interview-ready

Predict the Outcome

Six scenarios that come up in real orgs and real interviews.

Question 1 of 6 Score: 0

Cheat sheet: side by side

FutureQueueableBatchScheduled
StartsWhen resources are freeWhen resources are free, or after a 0–10 min delayWhen one of 5 slots frees upOn a cron schedule (at most hourly)
ParametersPrimitives onlyAny type, incl. sObjectsAny type via constructorAny type via constructor
Job IDNoYes (AsyncApexJob)Yes (AsyncApexJob)Yes (CronTrigger)
ChainingNoOne child per jobFrom finish()Starts other jobs
Calloutscallout=trueDatabase.AllowsCalloutsDatabase.AllowsCalloutsNot directly; hand off
LimitsAsyncAsyncAsync, reset per chunkSynchronous
Key cap50 per sync txn; 0 from batch/future50 per sync txn; 1 from async5 active, 100 in flex queue100 scheduled jobs
Best forExisting code; migrate itCallouts, follow-up work, retriesLarge-volume data jobsNightly 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.

Keep learning

Official Resources

Straight from Salesforce: the docs this article is based on.

Async jobs piling up or failing in your org?

Book a session with our architects to review your async design, limits and job monitoring.

Book Architecture Review

All information in this article was collected from publicly available resources, including official Salesforce documentation.