Skip to content

Expert Answers to Your Magento, Shopify & Shopware Questions

Vendor-neutral, engineer-written explanations. Clear definitions first, then practical steps with real examples — no fluff.

Stagebit builds and maintains stores on Magento, Adobe Commerce, Shopify, Shopware, and Laravel, and this library holds the questions our own engineers get asked most often on each platform.

How do I stop a Laravel queue from backing up?

SB
Written by Stagebit Engineering Team
Updated December 2026 6 min read Verified by engineers

A Laravel queue backing up means jobs go in faster than workers finish them, and the fix depends on which limit you hit. Workers may be too few, jobs may run too long, or jobs may fail and run again. Measure queue size and wait time first, then apply the matching fix below.

Quick answer

To stop a Laravel queue backing up, find the bottleneck first. Then add workers with Supervisor numprocs or Horizon auto balancing, keep --timeout several seconds below retry_after, and move slow jobs to their own queue. Schedule queue:monitor so you get an alert before the backlog grows. Extra workers only help when worker count is the bottleneck.

Common reasons for a Laravel queue backing up

  • Too few workers run for the job volume, so healthy jobs wait.
  • A few slow jobs, such as imports or ERP syncs, hold workers while quick jobs pile up.
  • Workers stop and nothing restarts them, so jobs sit stuck and processing halts without any error on screen.
  • A worker crashes or times out in the middle of a job. The job stays reserved until retry_after passes, then the queue releases it and another worker runs it again.
  • A job runs longer than retry_after. The queue releases it while the first worker is still busy, so two workers run the same job.
  • Jobs that throw exceptions go back on the queue for another attempt. With several attempts and no delay between them, one failing job keeps using worker time.
  • The app sits in maintenance mode, where workers handle no jobs unless you start them with --force.

Four numbers that show what is wrong

  • Queue size: how many jobs are waiting. A rising number means jobs arrive faster than they finish.
  • Queue wait time: how long a job waits before a worker starts it. This is what customers feel, such as a late order email.
  • Job runtime: how long one job takes once it starts. Long runtimes limit how many jobs each worker can finish.
  • Failed jobs: jobs that used all their attempts. Laravel stores them in the failed_jobs table when failed-job storage is configured. They do not return to the queue on their own.

More workers fix a short queue with normal runtimes. They do not fix slow jobs or failing jobs. If an API is the slow part, extra workers just send more requests to the same bottleneck.

Diagram of a Laravel queue: the app dispatches jobs to a queue, workers pick them up and complete them, jobs return to the queue after an exception or when retry_after passes, and jobs that use all attempts go to the failed_jobs table. Queue size, queue wait time, job runtime and failed jobs are marked.

Example: a slow ERP sync during a sale

Say every order dispatches a job that syncs it to an ERP system, and each sync takes 5 seconds. One worker finishes 12 syncs a minute. If the shop receives 30 orders a minute during a sale, the queue grows by 18 jobs a minute. These numbers are illustrative only.

Doubling the workers helps only if the ERP can handle twice as many requests at once. A better first move is to put ERP jobs on their own queue, set request timeouts, and add a few workers while you watch ERP response times. Order confirmation emails then stay on a separate queue and keep moving.

Check this before you change anything

Caution

Do not use queue:clear to fix a backlog. It deletes the jobs from the queue you name, so those orders, emails, or syncs never run. Clearing hides the symptom and loses work. On Horizon, use horizon:clear instead, and only for jobs you can safely discard.

Confirm Supervisor is running before you add capacity. A dead worker pool looks the same as a slow one.

More workers add load to your database, Redis, and any API your jobs call. Add them in small steps.

How to clear and prevent a queue backlog

  1. Measure the backlog: Schedule queue:monitor every minute with a threshold, for example php artisan queue:monitor redis:default --max=100. Replace redis:default with your own connection and queue names.

    When a queue passes the threshold, the command dispatches a QueueBusy event. Laravel sends no alert by itself, so register a listener that sends the notification you want.

    On Horizon, set long wait thresholds in the waits option, which defaults to 60 seconds for any connection and queue you leave undefined. Also schedule horizon:snapshot every five minutes to fill the Horizon metrics dashboard.

  2. Run workers under Supervisor and add capacity: A worker started in a terminal stops when the session ends. Supervisor restarts workers that exit, and raising numprocs adds more of them. The Laravel queue documentation shows an example running eight queue:work processes.
  3. Choose a Horizon balancing strategy:Laravel Horizon offers three strategies in config/horizon.php. Horizon requires Redis and does not support Redis Cluster.
    • auto is the default. It shifts worker processes between queues based on each queue’s workload, not strict priority.
    • simple splits the supervisor’s processes evenly across its queues and does not scale them.
    • false processes queues strictly in the order you list them. It still adds worker processes when jobs accumulate.

    With auto, minProcesses sets the minimum per queue. maxProcesses sets the maximum total processes the supervisor may scale to across all its queues. Keep it above the number of queues times minProcesses.

    'environments' => [
        'production' => [
            'supervisor-1' => [
                'connection' => 'redis',
                'queue' => ['default', 'notifications'],
                'balance' => 'auto',
                'minProcesses' => 1,
                'maxProcesses' => 10,
            ],
        ],
    ],
  4. Align timeouts: Keep --timeout at least several seconds shorter than retry_after in config/queue.php. This applies to queue connections that use retry_after. If a job is still running when the limit passes, the queue releases it and it can run twice.

    Amazon SQS has no such setting and uses its visibility timeout, which you manage in AWS, so the same logic applies there. The Horizon supervisor timeout follows the same rule.

  5. Make slow jobs faster: Laravel’s HTTP client waits up to 30 seconds for a response and 10 seconds to connect by default. Set limits that fit the API, for example Http::connectTimeout(3)->timeout(10), so a slow service cannot hold a worker.
    • Process large datasets in chunks instead of loading them into memory at once.
    • Select only the columns you need and index the columns you filter on.
    • Split a large import into smaller jobs so several workers can run them in parallel.
  6. Separate and prioritise queues: Give slow jobs their own queue and workers. Dispatch urgent jobs with ->onQueue('high') and start the worker with php artisan queue:work --queue=high,default,low. The worker checks the queues in that order whenever it looks for a job.

    If the high queue always has jobs, the lower queues can starve. On Horizon, strict order needs balance set to false, because auto shares workers by workload.

  7. Stop duplicate and looping jobs: Implement ShouldBeUnique so Laravel does not dispatch a job while an identical one is already queued or processing. By default the lock releases when the job completes or fails all its attempts. It needs a cache driver that supports atomic locks.

    It does not make a retried job safe. Make payment processing, order creation, and ERP syncs idempotent. For example, check whether the order already exists, or send an idempotency key where the API supports one.

  8. Control retries: By default Laravel attempts a job once. When you raise --tries, an exception releases the job back to the queue for another attempt, and without a backoff it retries immediately. Add a delay, for example php artisan queue:work redis --tries=3 --backoff=10.

    After the last attempt, Laravel marks the job as failed and stores it in failed_jobs. Review php artisan queue:failed, fix the cause, then run queue:retry.

    For rate-limited APIs, use the RateLimited job middleware. It releases jobs back to the queue, which uses up attempts, so allow enough of them. The ThrottlesExceptions middleware delays retries after repeated exceptions.

  9. Keep workers healthy: Use --max-time or --max-jobs so Supervisor restarts workers and frees memory. Run php artisan queue:restart on every deployment, because workers keep old code in memory. Set Supervisor stopwaitsecs above the runtime of your longest job.

What to do next

Start with step 1 so you know whether the queue is slow, stopped, or looping. Then change one thing at a time, so you can see which fix cleared the backlog. If the queue still backs up after that, check the database, Redis, and APIs your jobs depend on. Extra workers can only run as fast as those allow.

Running queues on a live Laravel app and want a second pair of eyes on the setup? See our Laravel development services.

Was this answer helpful?

Your feedback helps us improve our answers.

Still need help?

Questions about keeping your Laravel queue moving?

If you're weighing whether to add workers, split queues, or move to Horizon, we're happy to walk through what you're seeing and what your options are.

Talk to Laravel Experts