Know when to push background jobs to asynchronous queues with dispatch() versus executing them immediately in the current HTTP request process using dispatch_sync().
Laravel provides helper functions for pushing jobs to workers or executing them synchronously in the current process.
Understanding the difference makes sure background operations execute at the right time:
use App\Jobs\ProcessPdfExport;
use App\Jobs\UpdateUserStatus;
// Async: Pushes job to queue driver (Redis/Database) for worker execution
dispatch(new ProcessPdfExport($document));
// Sync: Executes job immediately inside current HTTP request process
dispatch_sync(new UpdateUserStatus($user));
dispatch(): Non-blocking, offloads long-running tasks to queue workersdispatch_sync(): Blocking, runs immediately inline without requiring an active queue worker- Handy for CLI commands and testing where immediate execution is required
Related Tips
View all tips →Monitor Aggregate Queue Metrics with Total Size Helpers in Laravel 13.27
Laravel 13.27 adds totalPendingSize(), totalDelayedSize(), and totalReservedSize() to the Queue facade, making it easy to aggregate queue metrics for dashboards and health checks.
Debounce Queued Event Listeners with #[DebounceFor] in Laravel 13.26
Laravel 13.26 extends the #[DebounceFor] attribute to queued event listeners, collapsing bursts of repeated events into a single execution based on the latest resource state.