-
-
Notifications
You must be signed in to change notification settings - Fork 218
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
Per-request cost #309
Comments
This sounds like a good idea! We could add a number/function option just like However, this will require us to make changes to the What do you think @nfriedly? Also, if we decide to implement this feature, @drmrbrewer would you like to make a PR for it? |
I've just noticed that |
You might want to try out https://www.npmjs.com/package/rate-limiter-flexible - it has a "points" concept that I believe matches what you're requesting - see https://github.com/animir/node-rate-limiter-flexible/wiki/API-methods#ratelimiterconsumekey-points--1-options-- |
@nfriedly thanks for the link, but I way prefer the relative simplicity of |
Description
First, thanks for this really useful module!
So far as I can tell, it's possible at present to set
max
, and each request will count as one towards that max quota.I'd find it useful to have a definable function which can set a per-request 'cost', so that some requests count as
1
towards the quota, while others count as more, e.g.2
or more.Why
If a request is using more server resources (based on the options passed in) then it should deplete its allowed quota more quickly and be rate limited sooner.
Alternatives
Could add multiple different limiters, each with different criteria and different
max
, but this seems overkill when a simplecost
function could be used.The text was updated successfully, but these errors were encountered: