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

Method for throttling #44

Open
roippi opened this issue Feb 5, 2021 · 3 comments
Open

Method for throttling #44

roippi opened this issue Feb 5, 2021 · 3 comments

Comments

@roippi
Copy link

roippi commented Feb 5, 2021

Hi, love the tool.

I have a list of somewhere around ~5k URLs to fetch from the CrUX API per day. When I run AWP on full blast, I blow through the 150 req/minute quota for the CrUX API and get Quota exceeded errors for the majority of requests. Is there any way to throttle the request rate down?

@roippi
Copy link
Author

roippi commented Feb 5, 2021

I can kind of do this via an extension, but as the extension system is currently written it needs to be a busy loop:

class ThrottleExtension extends Extension {

  afterRun(context, options) {
    const then = Date.now();
    while ((Date.now() - then) < 420) {
      // busy loop eew :(
    }
  }
}

More plumbing would let you e.g. return a Promise from extension hooks and clean that up. But again, maybe I'm going off the rails here, so want to get your feedback.

@gilbertococchi
Copy link
Collaborator

Hi Ben, nice to e-meet you!

That's a great idea, we didn't yet thought about adding a throttle on request rate just yet, we could limit the number of concurrent APIs being retrieved by the NPM CLI command if exceeding the 150q/min quota but it's up to the cronjob you have on your end to ask AWP again after 1min to trigger new APIs request on your end.

Do you think a similar setup would work on your case?
We can think about extending the CrUX API to work similarly to the WPT one that is considering the test Submit and Retrieval as different steps.

@roippi
Copy link
Author

roippi commented Feb 8, 2021

Howdy. I use jenkins for my scheduling/running, so pretty much any of the above works for me. I am running the job on a once per day cadence so it taking a long time is not a problem 😁

Here is my current solution for throttling via an extension. A production-ready version would be configurable and maybe have some tests 😁 stable...roippi:throttle_extension

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

2 participants