-
Notifications
You must be signed in to change notification settings - Fork 297
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
Atomic based limiter #15
Conversation
Hi @kriskowal, |
@kriskowal any thoughts here? |
This looks like a pretty fantastic change. Can you move the prior implementation into an internal package so we don’t grow the API surface? Sorry for the extraordinary delay. |
Hi @kriskowal |
Looks good. I’ll try to land, changelog, release this week. |
@storozhukBM where did you create this awesome benchmark visualization? |
@peakle |
Hi,
![limiter_scalability](https://user-images.githubusercontent.com/3532750/47335602-aa920400-d694-11e8-8eaa-a95e980e3024.png)
I've made your limiter implementation atomic based. It is a little bit harder but in generally faster and has no goroutine scalability issues that any mutex based implementation have.
Checkout this relation between RateLimiter latency and count of goroutines:
Original implementation moved to mutexbased.go file, so you can run benchmarks and play with other tests. But I'd suggest to leave only one implementation after all.
[Side note] This wired latency spike in mutex based implementation is a direct illustration of mutex falling into starvation mode.
Full benchmarking results here