brandur/redis-cell

Doubts about remaining value

Closed this issue · 3 comments

I think that the remaining value is incorrect, because it takes into account the max burst, but not the count per period.

2 examples explaining my point of view. I am doing request to CL.THROTTLE every ~250 milliseconds with the following configurations

Example with: CL.THROTTLE thekey 0 2 1

Req	millis	limited	limit	remaining retry	reset
1 	259 	0 	1 	0 	-1 	0
2 	533 	0 	1 	0 	-1 	0
3 	783 	0 	1 	0 	-1 	0
4 	1035 	0 	1 	0 	-1 	1
5 	1289 	0 	1 	0 	-1 	1
6 	1541 	1 	1 	0 	1 	1
7 	1790 	0 	1 	0 	-1 	1
8 	2040 	1 	1 	0 	1 	1

I would expect:

Req	millis	limited	limit	remaining retry	reset
1 	259 	0 	1 	2 	-1 	0
2 	533 	0 	1 	1 	-1 	0
3 	783 	0 	1 	1 	-1 	0
4 	1035 	0 	1 	0 	-1 	1
5 	1289 	0 	1 	0 	-1 	1
6 	1541 	1 	1 	0 	1 	1
7 	1790 	0 	1 	0 	-1 	1
8 	2040 	1 	1 	0 	1 	1

Example with: CL.THROTTLE thekey 2 2 1

Req	millis	limited	limit	remaining retry	reset
1 	259 	0 	3 	2 	-1 	0
2 	512 	0 	3 	1 	-1 	0
3 	765 	0 	3 	1 	-1 	0
4 	1016 	0 	3 	0 	-1 	1
5 	1268 	0 	3 	0 	-1 	1
6 	1519 	0 	3 	0 	-1 	1
7 	1769 	0 	3 	0 	-1 	1
8 	2021 	0 	3 	0 	-1 	2
9 	2273 	0 	3 	0 	-1 	2
10 	2523 	1 	3 	0 	1 	2
11 	2775 	0 	3 	0 	-1 	2
12 	3025 	1 	3 	0 	1 	2

I would expect:

Req	millis	limited	limit	remaining retry	reset
1 	259 	0 	3 	4 	-1 	0
2 	512 	0 	3 	3 	-1 	0
3 	765 	0 	3 	3 	-1 	0
4 	1016 	0 	3 	2 	-1 	1
5 	1268 	0 	3 	2 	-1 	1
6 	1519 	0 	3 	1 	-1 	1
7 	1769 	0 	3 	1 	-1 	1
8 	2021 	0 	3 	0 	-1 	2
9 	2273 	0 	3 	0 	-1 	2
10 	2523 	1 	3 	0 	1 	2
11 	2775 	0 	3 	0 	-1 	2
12 	3025 	1 	3 	0 	1 	2

What do you think @brandur? Am I forgetting something?

Thanks!!

And not only the remaining, I think limit has a similar problem: it is always max burst + 1

Following the theory, we have found the real problem and we have created a PR #13

Thanks for logging and sorry about the trouble! @javitonino's fix has been released as part of 0.2.2.