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

Need help applying multiple limiters #196

Open
viktorgullmark opened this issue Oct 12, 2021 · 0 comments
Open

Need help applying multiple limiters #196

viktorgullmark opened this issue Oct 12, 2021 · 0 comments

Comments

@viktorgullmark
Copy link

viktorgullmark commented Oct 12, 2021

Hey, didnt know where to turn exactly but I didnt see this covered in the docs.

I want to comply to the following headers: x-rate-limit: 15:10:60,30:300:300.

I have tried doing so by setting up the following and chaining them:

const limiter1 = new Bottleneck({
reservoir: 30,
reservoirRefreshAmount: 30,
reservoirRefreshInterval: 300 * 1000,
maxConcurrent: 1,
minTime: 500,
});

const limiter2 = new Bottleneck({
reservoir: 15,
reservoirRefreshAmount: 15,
reservoirRefreshInterval: 10 * 1000,
maxConcurrent: 1,
minTime: 500,
});

const chained = limiter1.chain(limiter2);

Since I create these at the same time, the reservoirRefreshInterval keeps ticking for the second limiter when its stuck waiting on the first one, so in theory too many requests could be sent in a shorter timespan.

Is there any way of complying to multiple limits like this?

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant