Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

meathanjay's avatar

Queue Rate Limiting

I am working on an app that requires fetching data from a third-party server and that server allows max 1 request per seconds.

Now, all request send as job and I am trying to implement Laravel "Rate Limiting" to release 1 job per second but unable to figure out why it should be implemented and there is no real-life example in the web.

Did anyone implement it?

Any hint of this?

0 likes
3 replies
ravickalex's avatar

It's explained in docs: https://laravel.com/docs/8.x/queues#job-middleware Anyway if you use Redis as driver you can put this logic inside a job:

Redis::throttle('key')->block(0)->allow(1)->every(5)->then(function () {
    info('Lock obtained...');

    // Handle job...
}, function () {
    // Could not obtain lock...

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

Also there is a new RateLimiter in Laravel 8 available. I hope this helps!

Please or to participate in this conversation.