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

Advanced rate limiter #142

Closed
jesus2099 opened this issue Jan 6, 2016 · 7 comments
Closed

Advanced rate limiter #142

jesus2099 opened this issue Jan 6, 2016 · 7 comments

Comments

@jesus2099
Copy link
Owner

I must try to understand this @kepstin advanced rate limiter.
He has left some useful explanations in IRC logs.

My rate limiter queues the requests and launch them at a rate of maximum 1 per second.

new request start time − previous request start time ≥ 1 second

His rate limiter would launch 10 simultaneous requests then make sure there is never more than 10 requests launched in 10 seconds, for the remaining queued requests.

It would make it very faster than mine for batches of 10 or less.

I have to find out the actual MB guidelines about rate limiting as kepstin says it would be max 10 requests within 10 seconds but Rate limiting says max 1 request per second (per IP) and I think I have read something like max 22(?) requests within 43(?) seconds in the 503 error slow down pages…

@jesus2099
Copy link
Owner Author

In the Slow Down page, we have this info :

« limit is {limit} per {period} seconds »

Where {limit} is the accepted amount of requests within {period} seconds.

I can’t make a dynamic rate limiter ; I didn’t find in the code where those values are set, I see they are read from socket data.
It’s only at run time that I could get up to date values (little bit too late). If a user script goes beyond limits, it could read the X-Rate-Limited header or parse that Slow Down page…

The spirit is still max 1 request per second but it seems accepted to proceed with @kepstin’s max 10 requests within 11 seconds.

@jesus2099
Copy link
Owner Author

Being able to launch around 10 initial requests (I would queue an empty slot first — for the already loaded current page — then 9 actual requests) could greatly improve MERGE HELPOR 2 and PENDING EDITS (associated artists).
It would not really enhance COLLECTION HIGHLIGHTER nor HYPER MOULINETTE, maybe it would even be hard to make them work with that engine (because IIRC each request requires the previous response).

@kepstin
Copy link

kepstin commented Jan 6, 2016

One thing to keep in mind is that you need to maintain a long-term average of 1 request/second even over multiple page loads or refreshes. E.g. what happens if someone opens a bunch of tabs where your script is running in all of them?

Unless you can coordinate the rate limit over multiple tabs and multiple page loads, I recommend using a simple 1 req/second method.

@jesus2099
Copy link
Owner Author

Thanks @kepstin, indeed !
So there’s only MERGE HELPOR 2 left, then — as we can’t open several different merge pages.

@jesus2099
Copy link
Owner Author

A solution to coordinate between multiple pages would be to store the queue in localStorage but that would be too much work for little gain.
When we open multiple tabs, we are not expecting all tabs to load fast, we don’t even go to all tabs fastly.

@jesus2099
Copy link
Owner Author

It may fix #115.

@jesus2099 jesus2099 added this to the 2020 milestone Feb 1, 2019
@jesus2099 jesus2099 modified the milestones: 2020, 2021 Aug 27, 2020
@jesus2099
Copy link
Owner Author

I close this now that #115 is fixed.
But this advanced rate limiter is so clever I wish I would use it in the future! :)

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

No branches or pull requests

2 participants