You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env)?
go env Output
$ go env
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
What did you do?
Library works good with limiting per one second but I would like to limit number of request in time period longer than second. For example allow 10 request in 60 seconds (burst = 10)
Here is example https://play.golang.org/p/OXyj7p3N9X9
What did you expect to see?
Limiter should block/reject after 11 request, because request every half second is too fast.
What did you see instead?
Limiter allow 120 requests in 60 seconds
The text was updated successfully, but these errors were encountered:
Your calculateLimitPerSecond function contains a bug. The division is an integer division and the result is 0. You need to convert the operands and not the result.
I have still problem with allowing more request than limit (10 per 60 seconds) In this example, limiter allow overall 38 requests (13 requests in first 58 seconds). Should it limit after 11 request?
Accuracy seems to be not good in big limiters like 300 per 3600 seconds.
I'm not sure why you are using a timer but assuming there are enough tokens in the limiter the request rate per minute is 60s * 1/4.5s = 13.3333 so the 13 req in 58s is correct.
And the total amount of request can be calculated by
f(x) = 10 + x * 10 / 60 # fill function
g(x) = - x * 1/4.5 # drain function
h = f + g
h(x) = 0 => x = 180
So after 180 seconds the pool is drained. With the request frequency of 1/4.5 this results in 40 total requests. I don't know why your result differs by 2 but overall the behavior of rate seems correct.
Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Library works good with limiting per one second but I would like to limit number of request in time period longer than second. For example allow 10 request in 60 seconds (burst = 10)
Here is example https://play.golang.org/p/OXyj7p3N9X9
What did you expect to see?
Limiter should block/reject after 11 request, because request every half second is too fast.
What did you see instead?
Limiter allow 120 requests in 60 seconds
The text was updated successfully, but these errors were encountered: