You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
👋 Trying to gauge if there would be interest in a feature to allow incrementing the "attempts" by a custom amount on the RateLimiter. Currently only the hit method is directly available which will increment by 1.
context
We did something similar for queue workers (by extending the base RateLimiter class) where we implemented a job middleware that grabs a tenant id for the job and times the time it took to execute the job in milliseconds. We increment the rate limit by the number of milliseconds spent and for any given tenant ID that's over a given limit, we re-queue the job on a separate queue.
This helps guarantee that the main queue is processing fast for all tenants and tenants that create too much work and are clogging the queue get moved to a separate queue where the work they created can be processed at a slower rate.
Since a job might take 300ms, we need a way to increment the rate limiting value by that amount directly.
implementation
I'm happy to contribute an implementation if there's interest in the feature.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
👋 Trying to gauge if there would be interest in a feature to allow incrementing the "attempts" by a custom amount on the RateLimiter. Currently only the
hit
method is directly available which will increment by1
.context
We did something similar for queue workers (by extending the base RateLimiter class) where we implemented a job middleware that grabs a tenant id for the job and times the time it took to execute the job in milliseconds. We increment the rate limit by the number of milliseconds spent and for any given tenant ID that's over a given limit, we re-queue the job on a separate queue.
This helps guarantee that the main queue is processing fast for all tenants and tenants that create too much work and are clogging the queue get moved to a separate queue where the work they created can be processed at a slower rate.
Since a job might take 300ms, we need a way to increment the rate limiting value by that amount directly.
implementation
I'm happy to contribute an implementation if there's interest in the feature.
Beta Was this translation helpful? Give feedback.
All reactions