Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.8] Added clarity on rate limiting for queues #5052

Closed
wants to merge 1 commit into
base: 5.8
from

Conversation

Projects
None yet
2 participants
@bkuhl
Copy link
Contributor

bkuhl commented Mar 12, 2019

Unfortunately throttling does not work when using sync as the queue driver, only when using redis. The documentation was incorrectly written in a way that gave the impression that merely having a redis connection is sufficient.

@bkuhl bkuhl changed the title Added clarity on rate limiting for queues [5.8] Added clarity on rate limiting for queues Mar 12, 2019

@taylorotwell

This comment has been minimized.

Copy link
Member

taylorotwell commented Mar 12, 2019

Eh, not sure this is true. I just confirmed it with my own sync job:

<?php

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Support\Facades\Redis;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;

class TestJob implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        Redis::throttle('key')->allow(1)->every(60)->then(function () {
            info('Job Ran...');
        }, function () {
            info('Job was throttled...');

            return $this->release(10);
        });
    }
}

Log file:

[2019-03-12 13:21:23] local.INFO: Job Ran...  
[2019-03-12 13:21:29] local.INFO: Job was throttled...  

@bkuhl bkuhl deleted the bkuhl:patch-1 branch Mar 13, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.