Knowledgebase

Handling Background Jobs and Queues Print

  • developersgitdeployment, developers, email, cron, performance, vps, webhosting, guide
  • 0

Work that should not happen during a page load.

WHY QUEUES EXIST

Sending email, processing images, calling external APIs and generating reports all take time. Doing them during a request makes the visitor wait and risks timeouts.

A queue accepts the job and processes it separately.

ON SHARED HOSTING

Persistent worker processes are generally not permitted. A worker running continuously conflicts with the shared model.

The practical approach is a cron job that processes the queue periodically: every minute or every five minutes, run the queue worker with a time limit so it exits.

Laravel supports this pattern directly.

THE LIMITATION

Jobs are processed in batches rather than immediately. For most purposes, a delay of a minute is acceptable.

For genuinely real-time processing, you need a VPS where a persistent worker can run.

ALTERNATIVES

External queue services process jobs off your server entirely.

WHAT TO PUT IN A QUEUE

Email sending, image processing, report generation, API calls, anything slow that the visitor does not need to wait for.


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot