brandur/redis-cell

does not work when parameters are large

Opened this issue · 4 comments

I downloaded the latest version and used it with redis server version 5.0.7, I tested cl.throttle command with both small and large parameters (small capacity + refilling speed, large capacity + refilling speed). The result shows that when capacity and refilling speed are both large, like 6000 at most, and every second 6000 (kind like a tps throttling), it does not work at all. Besides, cl.throttle a 6000 6000 1, gives the third parameter larger than 6000 capacity, very odd.

import redis
import time
client = redis.StrictRedis()

def start_throttle():
    n = 0
    while True:
        n += 1
        result = client.execute_command("cl.throttle", "a", 5, 3, 1)
# in another test, I used 6000, 6000, 1
        print n, result

I observed similar behaviour, e.g.

127.0.0.1:16379> CL.THROTTLE user123 1000 1000 60
1) (integer) 0
2) (integer) 1001
3) (integer) 1000
4) (integer) -1
5) (integer) 0
127.0.0.1:16379> CL.THROTTLE user123 1000 1000 60
1) (integer) 0
2) (integer) 1001
3) (integer) 1000
4) (integer) -1
5) (integer) 0
127.0.0.1:16379> CL.THROTTLE user123 1000 1000 60
1) (integer) 0
2) (integer) 1001
3) (integer) 1000
4) (integer) -1
5) (integer) 0
127.0.0.1:16379> KEYS *
(empty list or set)

No key for entry user123 is created and no counters are updated. Basically this configuration / parameters do not provide any rate limiting / throttling for the resource at all!

Maybe I don't understand the GCRA algorithm, but from my POV this clearly is a very serious bug.

Can please author comment?

Is this project still alive?

Hello @brandur,

could you please clarify semantics of max_burst parameter?
Is this project still active or have you abandoned it?

I'm having the same issue. Working with max_burst and count_per_period with numbers like 100 or 300 or 500.
Is it a code problem o an implementation problem? I'm working REDIS on docker.

For instance:
CL.THROTTLE user123 100 100 60

image

I ejecute the same command and the numbers does not change.
No redis key was created.

Please, @brandur can you help?
Thanks in advance.
Adrian.

Depending on used parameters (count, max_burst and period) the algorithm sets the expiration of keys only for fraction of second in some cases.
If you set keyspace notifications you will notice the keys (dis)appearing.
https://redis.io/topics/notifications