When a queue backs up, nobody gets an error. The password reset email just arrives four minutes late, by which point the user has requested three more. Queue latency is the delay between dispatching work and a worker actually starting it, and it's the part of background processing your users feel most directly, even though it never shows up as a failure. A healthy-looking queue with zero failed jobs can still be quietly ruining the experience if the wait time has crept up.
Latency vs runtime: the two halves
Perceived job delay = queue latency + job runtime. They're separate problems:
| Problem | Cause | Fix |
|---|---|---|
| High queue latency | Not enough worker capacity for dispatch rate | Scale workers or split queues |
| High runtime | The job itself is slow (DB, external API, computation) | Optimize or decompose the job |
Measuring latency yourself
Laravel fires JobProcessing when a worker picks up a job. Every queued payload includes createdAt, a Unix timestamp in seconds set at dispatch, so the resolution is one second. For a delayed job, the wait includes the delay you asked for. Register the listener in AppServiceProvider::boot():
app/Providers/AppServiceProvider.php
<?php
namespace App\Providers;
use Illuminate\Queue\Events\JobProcessing;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
public function boot(): void
{
Event::listen(function (JobProcessing $event) {
$createdAt = $event->job->payload()['createdAt'] ?? null;
if ($createdAt === null) {
return;
}
DB::table('queue_latency')->insert([
'queue' => $event->job->getQueue(),
'job_class' => $event->job->resolveName(),
'attempt' => $event->job->attempts(),
'latency_ms' => max(0, (microtime(true) - $createdAt) * 1000),
'started_at' => now(),
]);
});
}
}
On PostgreSQL, aggregate with percentile_cont(0.95) WITHIN GROUP (ORDER BY latency_ms), grouped per queue per minute. A retried job keeps its original createdAt, so filter on attempt = 1 if you only want the first wait.
Per-queue SLOs
Assign each queue a latency target based on what it serves. These figures are starting points, not a standard:
| Queue | Work type | SLO (p95) |
|---|---|---|
| transactional | Password resets, 2FA codes | < 3s |
| default | User notifications, light background work | < 15s |
| indexing | Search index updates | < 60s |
| batch | Nightly exports, bulk imports | < 10m |
Separate fast from slow
Mixing fast and slow jobs on the same queue with the same workers is a common cause of latency spikes. A 5-second job class that fires 100 times floods the queue and starves the sub-second email jobs behind it. Fix it by splitting queues and dedicating workers. Don't declare a public $queue property on the job: the Queueable trait already defines $queue, and redeclaring it with a default value is a fatal error. Call onQueue() in the constructor instead:
app/Jobs/SendPasswordResetEmail.php
public function __construct(public User $user)
{
$this->onQueue('transactional');
}app/Jobs/GenerateMonthlyReport.php
public function __construct(public int $month)
{
$this->onQueue('batch');
}
Supervisor needs the absolute path to artisan, and a process_name containing %(process_num) when numprocs is above 1. A worker's --timeout must be shorter than the connection's retry_after (90 seconds by default in config/queue.php), or a long job gets handed to a second worker while the first is still running it. The batch worker below uses a separate redis-long connection with retry_after set to 660:
supervisord config
[program:laravel-transactional-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/app/artisan queue:work redis --queue=transactional --sleep=0 --tries=3
autostart=true
autorestart=true
numprocs=5
stopwaitsecs=60
[program:laravel-batch-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/app/artisan queue:work redis-long --queue=batch --sleep=3 --timeout=600 --tries=1
autostart=true
autorestart=true
numprocs=2
stopwaitsecs=660Alerting on backlog
Alert on the age of the oldest pending job rather than the count. Laravel 12's queue drivers expose creationTimeOfOldestPendingJob(), which returns a Unix timestamp (or null for an empty queue) and skips delayed jobs. Schedule the check in routes/console.php:
routes/console.php
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Queue;
use Illuminate\Support\Facades\Schedule;
Schedule::call(function () {
$oldest = Queue::connection('redis')
->creationTimeOfOldestPendingJob('transactional');
if ($oldest === null) {
return;
}
$ageSeconds = now()->getTimestamp() - $oldest;
if ($ageSeconds > 10) {
// Swap for a notification to your on-call channel.
Log::critical('Transactional queue lag', ['age_seconds' => $ageSeconds]);
}
})->everyMinute()->name('check-transactional-queue-lag')->withoutOverlapping();
For a count-based check, php artisan queue:monitor redis:transactional --max=100 dispatches a QueueBusy event when the queue reaches 100 jobs. Schedule it every minute and listen for the event to send the alert.
Point-in-time isn't enough
The trap with queue monitoring is watching the current backlog. A dashboard that shows "0 pending jobs right now" looks reassuring and tells you nothing about the 9am spike where the transactional queue sat at 40 seconds of lag for twenty minutes. By the time you look, it has drained. Latency is a distribution over time, not a number you glance at. The queue_latency table above gives you p95 wait per queue over hours and days, so the recurring 9am problem shows up as a shape on a graph. On Redis, Horizon's dashboard shows only the current wait, not its history.
NightOwl covers the other half and the per-job view. Each job class page charts processing time (avg, p50, p95, p99) alongside processed, released and failed attempts, and the attempts list filters to runs at or above p95. Open an attempt and the trace timeline shades the gap before it started; hover it to read the queue wait for that attempt. It doesn't chart wait time per queue or per class, so keep the listener for trends.