Skip to content

Commit

Permalink
feat: truncate suspicious_ips when it exceed the max_size
Browse files Browse the repository at this point in the history
  • Loading branch information
jopemachine committed Apr 30, 2024
1 parent 1773971 commit be22862
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/ai/backend/manager/api/ratelimit.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@
-- Add IP to suspicious_ips only if count is greater than score_threshold
if rolling_count >= score_threshold then
redis.call('ZADD', 'suspicious_ips', rolling_count, id_value)
local max_size = 1000
local current_size = redis.call('ZCARD', 'suspicious_ips')
if current_size > max_size then
redis.call('ZREMRANGEBYRANK', 'suspicious_ips', 0, 0)
end
end
end
Expand Down

0 comments on commit be22862

Please sign in to comment.