Background jobs

Queue work reliably with Redis-backed Atlas jobs.

Move slow or unreliable work off the request cycle. Atlas jobs run on Redis by default and support delayed, batched, and unique executions.

Dispatch a job

phpapp/Http/Controllers/InvoiceController.php
ProcessInvoice::dispatch($invoice)
    ->onQueue('billing')
    ->delay(now()->addMinutes(2));

Job skeleton

phpapp/Jobs/ProcessInvoice.php
class ProcessInvoice implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    public function __construct(public Invoice $invoice) {}

    public function handle(BillingGateway $billing): void
    {
        $billing->settle($this->invoice);
    }
}

Operational checklist

  1. Run php atlas queue:work --queue=billing,default in production.
  2. Monitor failed_jobs and retry with exponential backoff.
  3. Keep payloads small — pass IDs, not entire Eloquent graphs.
Warning
Never use the sync driver in production. It hides race conditions that only appear under load.
Unique jobs
Unique jobs prevent duplicate work when webhooks retry. Implement ShouldBeUnique and define a uniqueId() method keyed by the business resource.

Updated Aug 5, 2026