spacewander commented on code in PR #8578:
URL: https://github.com/apache/apisix/pull/8578#discussion_r1058122572
##########
apisix/plugins/limit-count/init.lua:
##########
@@ -300,9 +327,28 @@ function _M.rate_limit(conf, ctx)
return 500, {error_msg = "failed to limit count"}
end
+ local reset
+ if remaining == conf.count - 1 then
+ -- set an end time
+ local end_time = ngx_time() + conf.time_window
+ -- save to lrucache by key
+ reset = conf.time_window
+ local end_time_obj = get_end_time(conf,key)
Review Comment:
By default, the client IP will be used as key, which means there will be a
great number of keys per conf. The size of lrucache is limited.
There come two solutions:
1. store the end time info in the actual backend like redis cluster.
~~2. write a new cache with dynamical expire support to store the end time
info, but this way is not memory-effective.~~(it doesn't work)
Personally, I prefer solution 1.
--
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]