I am building an application which includes a scraper of a public API. I want to limit the rate of my requests but not with a fixed rate, but a dynamic randomised rate which changes in-between requests and falls in a certain range, i.e. I can set the minimum and maximum delay between requests.
I also don't want to block the current thread.
I've researched Guava Ratelimiter, RatelimitJ and Token bucket algorithm but looking at the docs, I don't see how any of those things can achieve what I want.
Example of the desired effect on my requests given a rate limit range of 250-350ms:
- Make request #1
- wait 321ms
- Make request #2
- wait 259ms
- Make request #3
- wait 337ms
- ...