Development › Queues

Queues

Laravel queues handle deferred work: mail, notifications, outbox publishing, CPU-heavy jobs, and retries.

#Connections

Configure via QUEUE_CONNECTION:

ValueUse
syncTests / simple local scripts
databaseEasy local/dev without Redis
redisRecommended for production workers

#Workers

Run workers separately from the HTTP process:

php artisan queue:work --tries=3 --timeout=90

In Docker, the worker service runs queue (and optionally Kafka consumer) processes. Scale horizontally:

docker compose up --scale worker=5

#What belongs on a queue

Keep Application Actions synchronous for the core business transaction; dispatch jobs for side effects when eventual consistency is acceptable.

#Reliability

  1. Make jobs idempotent where retries are possible.
  2. Use --tries and failed-job handling (queue:failed).
  3. Prefer small payloads (IDs, not large graphs).
  4. Set sensible timeouts; long work should be chunked.

#Scheduling

Use Laravel’s scheduler (routes/console.php / bootstrap/app.php schedule) for cron-like tasks. The scheduler should only enqueue work; workers execute it.

Edit this page on GitHub