-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
the RateLimiter Limit::perSecond
not working as expected for the queue jobs
#53157
Comments
Seems to be a conflict when combining the rate limiters. In isolation, I can see each working as expected. When combined into a single limiter, they are conflicting somewhere. Extracting two individual limiters and applying them together is working as expected. RateLimiter::for('webservice_api_1', fn () => [
Limit::perSecond(1),
]);
RateLimiter::for('webservice_api_2', fn () => [
Limit::perMinute(30),
]); Looking into this one. |
@timacdonald Why not simply prefix array keys into actual generated keys? |
@amir9480, prefixing array keys will mean if you change the order of the limits it will break existing rate limit hits - which is very unexpected and a subtle bug that could break systems. Pretty much every fix for this breaks something, but I've found one fix that I think fixes this and introduces another caveat that is more acceptable. |
p.s., that page does not document how to create named rate limiters or using a list of limits. That documentation is on the routing page. |
Laravel Version
11.27.2
PHP Version
9.3.12
Database Driver & Version
No response
Description
I tried to use the new Laravel jobs per second rate limiter as described by @timacdonald in #48498.
we are using a third-party web service with the following rate limits:
I used the following config for the rate limit:
Expected output:
Limit job 1/second and 30/minute.
Actual output:
The job is always rate-limited and does not execute at all.
Steps To Reproduce
AppServiceProvider
:php artisan queue:work
Expected behavior:
Execute one job per second.
Actual behavior:
Not executing at all and always rate limited.
The text was updated successfully, but these errors were encountered: