In the governor code for .per_second(max_burst), the replenishment interval is set as 1 / max_burst seconds. But in the actix-governor code for .per_second(period), the replenishment period is set to be the passed in number of seconds. That is, .per_second(2) only allows an average of one request every 2 seconds, not 2 per second.
I've verified this by running:
$ for i in (seq 20); curl http://localhost:8080/...; echo; sleep .5; end
After the initial burst, only 1 out of every 4 requests succeeds. With .per_second(2), I would expect every request to succeed.
To get 2-per-second, I have to configure .per_millisecond(500), which I'd similarly have expected to mean "500 per millisecond", not "1 per every 500 milliseconds".
In the governor code for
.per_second(max_burst)
, the replenishment interval is set as1 / max_burst
seconds. But in the actix-governor code for.per_second(period)
, the replenishment period is set to be the passed in number of seconds. That is,.per_second(2)
only allows an average of one request every 2 seconds, not 2 per second.I've verified this by running:
After the initial burst, only 1 out of every 4 requests succeeds. With
.per_second(2)
, I would expect every request to succeed.To get 2-per-second, I have to configure
.per_millisecond(500)
, which I'd similarly have expected to mean "500 per millisecond", not "1 per every 500 milliseconds".