go-redis / redis_rate

Rate limiting for go-redis
https://redis.uptrace.dev/guide/go-redis-rate-limiting.html
BSD 2-Clause "Simplified" License
824 stars 102 forks source link

What's the difference between rate and burst? #58

Open birdycn opened 3 years ago

birdycn commented 3 years ago
    limit := redis_rate.Limit{
        Rate:   limitCfg.Burst,
        Burst:  limitCfg.Burst,
        Period: time.Duration(limitCfg.Second) * time.Second,
    }

Many times, the same values are used. What's the difference between them

vmihailenco commented 3 years ago

In the leaking bucket analogy the burst is the initial water level in the bucket. Without it the first call to the rate limiter will fail (bucket will be empty).

jose-zenledger commented 1 year ago

@vmihailenco in the analogy, wouldn't requests fail when the bucket is full? New requests raise the water level and leak out when complete? In that interpretation I think everything works.

Either way the result is that the rate limiter doesn't rate limit so shouldn't this be patched?

aleksficek commented 1 year ago

@jose-zenledger your analogy makes sense with how leaky bucket works, not sure what @vmihailenco is saying here

whongki commented 11 months ago

@vmihailenco in the analogy, wouldn't requests fail when the bucket is full? New requests raise the water level and leak out when complete? In that interpretation I think everything works.

Either way the result is that the rate limiter doesn't rate limit so shouldn't this be patched?

I feel like it's more a token bucket than a leaky bucket. That's why the water level is zero, you can not have request. the water level here works like a token.