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

Rate-limited/bounded/windowed parallelism. #48

Open
alexanderkjeldaas opened this issue Feb 9, 2018 · 1 comment
Open

Rate-limited/bounded/windowed parallelism. #48

alexanderkjeldaas opened this issue Feb 9, 2018 · 1 comment

Comments

@alexanderkjeldaas
Copy link

What I most often need is something that is rate-limited by some external service. Say I must guarantee that I don't do more than X requests/second.

I'm not sure if this is supported by the parallelism modes.

I guess it's possible to use asyncly and then consume using Control.Concurrent.Async.race System.Sleep.sleep (1/rate) restOfComputation.

?

@andrewthad
Copy link
Contributor

I’ve not done this exactly thing before but you may be able to get away without using any concurrency related stuff to get this behavior. You should be able to write a function that consumes a stream, sampling the system clock every time an element comes in. It can buffer things until the right amount of time has elapsed. But it could run into weird situations where the buffer wouldn’t clear until a new element showed up. So, you’d probably need a timer running concurrently to address that.

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