CLOUD
Guides

Background Job Queues: Do Not Make the User Wait

CLOUD|August 12, 2026|5 min read|262 views
Background Job Queues: Do Not Make the User Wait

The queue concept, practical examples, Redis versus the database driver, managing workers with Supervisor, and production tips with Laravel as an example.

Why You Need Background Job Queues

Background job queues let your application run heavy tasks away from the direct request, so the user does not sit waiting in front of a frozen screen. Instead of the user waiting 8 seconds for a welcome email to be sent, an image to be processed, and a report to be updated, they receive the response instantly within a fraction of a second, and the rest of the work happens in the background without them noticing. The core idea: separate what the user needs to see now from what can happen a moment later.

The difference is tangible in numbers: a request that takes 6 seconds because it sends an email and processes an image drops to under 200 milliseconds once you move those tasks to a background queue. The user experience improves dramatically, and the server handles more requests with the same resources because it does not lock web processes waiting on slow tasks. This difference decides whether your application feels fast or heavy.

Examples of Tasks That Go to the Queue

Any task that takes time and whose result the user does not need immediately is a candidate for the queue:

  • Sending email: welcome emails, password resets, notifications. Connecting to the mail server can take seconds, so there is no reason to lock the user during it
  • Image processing: resizing uploaded images, creating versions at different sizes, compressing them. Operations that consume CPU and take time
  • Report generation: a large PDF report or an Excel export of thousands of rows takes time, so it is generated in the background and its link sent once ready
  • Calling external services: sending a WhatsApp message through an API or syncing data with another system, tasks that depend on a third party's response that may be delayed

The rule: if the task takes more than half a second and the user does not need its result on the same screen, move it to a queue. Your application becomes faster and more stable.

Redis versus the Database Driver

The queue needs a place to store pending jobs, and here you choose the driver. The two most common options:

  • database: stores jobs in a table in your database. Easy to set up, needs no extra service, and suits small and mid-size applications with a reasonable job volume. Its drawback is being relatively slower because it relies on the database
  • Redis: stores jobs in fast memory, much quicker and able to handle huge numbers of jobs per second. The preferred choice for large-scale production, in exchange for running and managing a Redis service

A practical tip: start with the database driver if your volume is small, because it is simpler and sufficient. When the job count grows and you notice pressure on the database, move to Redis. The transition is usually easy because it happens by changing a single setting in modern frameworks.

Supervisor for Managing Workers

A worker is the process that pulls jobs from the queue and runs them. The problem: if the worker stops for any reason (an error, a restart, memory exhaustion), queue processing halts entirely and jobs pile up. The solution is Supervisor, a tool that monitors workers and restarts them automatically if they stop.

You configure Supervisor to run a set number of workers and keep them running at all times. If a worker dies, Supervisor brings it back within seconds. You can run several workers in parallel to process more jobs at once, and tune their count to your server resources and queue size. Without Supervisor or a similar alternative, running workers in production stays fragile and unreliable.

Production Tips

Running queues on a production server needs attention to several points to stay reliable:

  • Redeploy workers after every update: a worker loads the code into memory when it starts, so after deploying an update you must restart the workers to run the new code
  • Configure retries: set how many times a failed job is retried before it is considered permanently failed, so a broken job does not loop forever
  • Monitor failed jobs: modern frameworks store failed jobs in a separate table, review it regularly and re-run what deserves it
  • Separate queues by priority: put critical jobs (verification email) in a high-priority queue and heavy jobs (reports) in a separate queue, so the heavy ones do not block the fast ones

In Laravel for example, the queue system is ready and built in: you define the job as a class, dispatch it to the queue with a single call, run the worker with the queue:work command, and manage it with Supervisor. The same concepts exist in other frameworks under different names, but the principle is one: separate the heavy from the fast.

At CLOUD, your server in the Riyadh data center gives you a complete environment to run your application with Redis, Supervisor, and workers under your control, with resources you choose to match your queue volume. A fast application starts from stable infrastructure close to your users, where background jobs run without interruption and latency for the Saudi user stays close to 8ms.

Share