udoprog / leaky-bucket

A token-based rate limiter based on the leaky bucket algorithm.
Apache License 2.0
93 stars 10 forks source link

Store tasks to wake up locally in order to make coordinator more fair #8

Closed udoprog closed 4 years ago

udoprog commented 4 years ago

This resurrects the local task queue that was used in 0.7 for the coordinator, which consumes the tasks to be woken up more eagerly than what is currently done. This should avoid tasks being overly stuck in the task queue.

Do note that the "fast path" is still best effort. And spurious slowdowns of one refill cycle or more can still happen under the right conditions (a task is added while the fast path is being refilled). So the error one should be expecting should be around one or two refill cycles depending on circumstances.

This was reported here: https://github.com/udoprog/leaky-bucket/issues/5#issuecomment-703290390 and created as an issue in #9

@xnuter - please take it for a spin

xnuter commented 4 years ago

I tested the latest changes and it seems the rate is correct + coordinator tasks are being dropped. Thanks!

udoprog commented 4 years ago

Thanks for giving it a shot @xnuter!

udoprog commented 4 years ago

0.8.2 is now out with this. Hope it helps!

xnuter commented 4 years ago

It works after upgrading to 0.8.2, thanks!