feat: resty.limit.count support new shared dict incr function#67
Merged
Conversation
doujiang24
reviewed
Nov 4, 2021
| return 0, remaining | ||
| end | ||
|
|
||
| function _M.incoming(self, key, commit) |
Member
There was a problem hiding this comment.
This way should be better:
local function incoming_new
local function incoming_old
_M.incomming = incr_support_init_ttl and incoming_new or incoming_old
Contributor
Author
There was a problem hiding this comment.
@doujiang24 fixed, please review again, thanks
doujiang24
approved these changes
Nov 4, 2021
zhuizhuhaomeng
approved these changes
Nov 4, 2021
monkeyDluffy6017
pushed a commit
to monkeyDluffy6017/lua-resty-limit-traffic
that referenced
this pull request
Apr 19, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi,
The aim of this pr is to make
resty.limit.count's incoming function using the latest type of shared dict'sincrfunction, which supports setting expire time when increasing an unexisting key, and it is also compatible with the old version of OpenResty, just as mentioned in #34 (comment).I'm doing some pressure tests recently to test the stability of lua-resty-limit-traffic module and found some problems under high volume(possibly due to the concurrent situation and two separate atomic operation(incr and expire) calls in
incoming, see #23 (comment) and #47 (comment)). However, I found that when I'm using the latestincrfunction which supports expire time(which makes the two operation combines into an atomic one(done within the same lock, see https://github.com/openresty/lua-nginx-module/blob/3f33dd862a3d8539b96dda09b624c89712cbe0c8/src/ngx_http_lua_shdict.c#L1889), the problem hardly occurs. So I think it is perhaps a good idea to use incr with expire time arg instead of separate them into two operations.