-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(queue): added a new configuration concurrency_limit
(integer, default to 1) for Queue to specify the number of delivery timers
#13332
Conversation
I think the new behavior should be enabled by an explicit configuration parameter ( |
kong/plugins/http-log/handler.lua
Outdated
local entry = cjson.encode(kong.log.serialize()) | ||
|
||
if queue_conf.max_batch_size == 1 then | ||
local ok ,err = timer_at(0, function() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the TPS is very high, the number of timers would soar. Would that be a problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose all the timers would be managed by timer-ng
since 3.0. In that case, there will be warning logs from the timer-ng
.
Co-authored-by: Hans Hübner <hans.huebner@gmail.com>
39645d8
to
3acafc9
Compare
3acafc9
to
6b92162
Compare
@@ -0,0 +1,3 @@ | |||
message: "**HTTP-Log**: Added a new configuration `queue.concurrency`" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's also explain what this is for
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated. It May require a second review.
@@ -210,5 +211,17 @@ return { | |||
acl = { | |||
"always_use_authenticated_groups", | |||
}, | |||
http_log = { | |||
"queue.concurrency", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a feature. Can we catch up 3.8.0.0
? If not, we should put it under 3.9.0.0
.
|
||
if (now() - start_time) > self.max_retry_time then | ||
self:log_err( | ||
"could not send entries due to max_retry_time exceeded. %d queue entries were lost", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"could not send entries due to max_retry_time exceeded. %d queue entries were lost", | |
"failed to send %d entries due to maximum timeout reached.", |
spec/01-unit/01-db/01-schema/11-declarative_config/02-process_auto_fields_spec.lua
Outdated
Show resolved
Hide resolved
spec/01-unit/01-db/01-schema/11-declarative_config/02-process_auto_fields_spec.lua
Outdated
Show resolved
Hide resolved
spec/01-unit/01-db/01-schema/11-declarative_config/02-process_auto_fields_spec.lua
Outdated
Show resolved
Hide resolved
spec/01-unit/01-db/01-schema/11-declarative_config/02-process_auto_fields_spec.lua
Outdated
Show resolved
Hide resolved
spec/01-unit/01-db/01-schema/11-declarative_config/03-flatten_spec.lua
Outdated
Show resolved
Hide resolved
spec/01-unit/01-db/01-schema/11-declarative_config/03-flatten_spec.lua
Outdated
Show resolved
Hide resolved
spec/01-unit/01-db/01-schema/11-declarative_config/03-flatten_spec.lua
Outdated
Show resolved
Hide resolved
spec/01-unit/01-db/01-schema/11-declarative_config/03-flatten_spec.lua
Outdated
Show resolved
Hide resolved
concurrency_limit
(integer, default to 1) for Queue to specify the number of delivery timers
kong/tools/queue.lua
Outdated
@@ -506,6 +514,21 @@ local function enqueue(self, entry) | |||
return nil, "entry must be a non-nil Lua value" | |||
end | |||
|
|||
if self.concurrency_limit == -1 then -- unlimited concurrency | |||
-- do not enqueue when concurrency_limit is unlimited | |||
local ok, err = timer_at(0, function(premature) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found some places use kong.timer
, so we do not need to declare ngx.timer.at
spearately.
it would be good to perf-test the final solution and compare results with the initial "fix" to ensure we get similar performance |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM except a minor changelog syntax.
Co-authored-by: Zachary Hu <6426329+outsinre@users.noreply.github.com>
Cherry-pick failed for Please cherry-pick the changes locally. git remote add upstream https://github.com/kong/kong-ee
git fetch upstream master
git worktree add -d .worktree/cherry-pick-13332-to-master-to-upstream upstream/master
cd .worktree/cherry-pick-13332-to-master-to-upstream
git checkout -b cherry-pick-13332-to-master-to-upstream
ancref=$(git merge-base b6315737104d65c670f9c48001b2ee4b7d470ee4 ff1a7e17e1cfe222e45fcf58b099f3305893f3ae)
git cherry-pick -x $ancref..ff1a7e17e1cfe222e45fcf58b099f3305893f3ae |
Cherry-picked in Kong/kong-ee#9996 |
…efault to 1) for Queue to specify the number of delivery timers (#13332) Added a new configuration concurrency_limit(integer, default to 1) for Queue to specify the number of delivery timers. Note that setting concurrency_limit to -1 means no limit, and each HTTP Log will create a individual timer to send. FTI-6022
Summary
Added a new configuration
concurrency_limit
(integer, default to 1) for Queue to specify the number of delivery timers.Note that setting concurrency_limit to -1 means no limit, and each HTTP Log will create a individual timer to send.
Checklist
changelog/unreleased/kong
orskip-changelog
label added on PR if changelog is unnecessary. README.mdIssue reference
FTI-6022