New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

mxl/laravel-queue-rate-limit

Simple Laravel queue rate limiting
514,532 93
Install
composer require mxl/laravel-queue-rate-limit
Latest Version:v3.6.1
PHP:^7.3||^8.0
Laravel:7 – 12
Older releases:5 · 6
License:MIT
Last Updated:Apr 29, 2026
Links: GitHub  ·  Packagist
Maintainer: mxl

laravel-queue-rate-limit

Current version Monthly Downloads Total Downloads Build Status

Simple Laravel queue rate limiting

Installation

3.* versions are compatible only with Laravel 7+.

$ composer require mxl/laravel-queue-rate-limit

For Laravel 6 use 2.* versions:

$ composer require mxl/laravel-queue-rate-limit "^2.0"

For Laravel 5 use 1.* versions:

$ composer require mxl/laravel-queue-rate-limit "^1.0"

Laravel 5.5+ will use the auto-discovery feature to add MichaelLedin\LaravelQueueRateLimit\QueueServiceProvider::class to providers.

This package is not compatible with older Laravel versions.

Add rate limits to config/queue.php:

'rateLimits' => [
    'mail' => [ // queue name, not connection name
        'allows' => 1, // 1 job
        'every' => 5 // per 5 seconds
    ]
]

The rateLimits array keys must match the queue names your worker processes. For example, if your database connection uses queue.connections.database.queue set to payments, configure rateLimits.payments and run the worker for that queue:

// config/queue.php
'connections' => [
    'database' => [
        'driver' => 'database',
        'queue' => 'payments',
        // ...
    ],
],

'rateLimits' => [
    'payments' => [
        'allows' => 1,
        'every' => 60,
    ],
],
$ php artisan queue:work database --queue payments

If you dispatch jobs to a non-default queue, make sure the job uses the same queue name:

PaymentJob::dispatch($details)->onQueue('payments');

This package rate-limits when workers pop jobs from queues. It does not delay jobs when they are dispatched and does not change available_at in the jobs database table. For database queues, seeing available_at equal to created_at is expected unless you dispatch the job with Laravel's own delay API.

Usage

Make sure that you don't use sync connection when queueing jobs. See default property in config/queue.php.

Run queue worker:

$ php artisan queue:work --queue default,mail

Then push several jobs to default and mail queues:

Mail::queue(..., 'mail');
Mail::queue(..., 'mail');
Mail::queue(..., 'mail');
Mail::queue(..., 'default');
Mail::queue(..., 'default');

You'll see that only mail queue jobs will be rate limited while default queue jobs will run normally.

Disable logging

Extend QueueServiceProvider:

<?php

namespace App\Providers;

class QueueServiceProvider extends \MichaelLedin\LaravelQueueRateLimit\QueueServiceProvider
{
    protected function registerLogger()
    {
        $this->app->singleton('queue.logger', function () {
            return null;
        });
    }
}

Add it to providers array in config/app.php:

<?php

return [
    // ...
    'providers' => [
        // Laravel Framework Service Providers
        // ...
        // Application Service Providers
        // ...
        App\Providers\QueueServiceProvider::class,
        // ...
    ]
];

Maintainers

Other useful Laravel packages from the author

License

See the LICENSE file for details.

Related Packages

laravel/horizon

Dashboard and code-driven configuration for Laravel queues.

121,058,683 4,179
queueworker/sansdaemon

Batch process Laravel Queue without a daemon; Processes queue jobs and kills the...

205,266 178
kingdarkness/lumen-horizon

Dashboard and code-driven configuration for Laravel queues.

9,765 3
arxeiss/sansdaemon

Batch process Laravel Queue without a daemon; Processes queue jobs and kills the...

6,494 9
rocketfy/horizon

Dashboard and code-driven configuration for queues.

2,343 0

Version History

Version Released PHP Laravel License
v3.6.1 ^7.3||^8.0 ^7.0||^8.0||^9.0|^10.0||^11.0||^12.0 MIT
v3.6.0 ^7.3||^8.0 ^7.0||^8.0||^9.0|^10.0||^11.0||^12.0 MIT
v3.5.0 ^7.3||^8.0 ^7.0||^8.0||^9.0|^10.0||^11.0 MIT
v3.4.0 ^7.3||^8.0 ^7.0||^8.0||^9.0|^10.0 MIT
v3.3.0 ^7.3||^8.0 ^7.0||^8.0||^9.0 MIT