98001yash commented on issue #13079:
URL: https://github.com/apache/apisix/issues/13079#issuecomment-4018129219

   I investigated the implementation in `limit-count-redis.lua`.
   
   The Redis script intentionally stores the **remaining quota** instead of the 
**consumed request count**.
   
   For example, with a limit of 5:
   
   Request 1 → Redis value = 4
   Request 2 → Redis value = 3
   Request 3 → Redis value = 2
   Request 4 → Redis value = 1
   Request 5 → Redis value = 0
   
   This behavior comes from the Lua script:
   
   ```
   redis.call('set', KEYS[1], ARGV[1] - ARGV[3], 'EX', ARGV[2])
   redis.call('incrby', KEYS[1], 0 - ARGV[3])
   ```
   
   So Redis is tracking **remaining quota**, not **consumed requests**.
   
   Rate limiting itself appears to work correctly.
   
   Could you confirm whether this behavior is intentional, or if Redis should 
instead track the consumed request count?
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to