-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
perf: simple setup upstream #8130
Conversation
# Conflicts: # apisix/plugins/ai.lua # t/plugin/ai.t
balancer.enable_keepalive(60, 1000) | ||
else | ||
balancer.set_current_peer(server.host, server.port or 80) | ||
end |
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.
We can move:
if enable_keepalive then
to here?
Like:
if enable_keepalive then
balancer.enable_keepalive(60, 1000)
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.
maybe not, follow:
Lines 291 to 338 in ecdc209
if enable_keepalive then | |
if not keepalive_pool then | |
if not default_keepalive_pool then | |
local local_conf = core.config.local_conf() | |
local up_keepalive_conf = | |
core.table.try_read_attr(local_conf, "nginx_config", | |
"http", "upstream") | |
default_keepalive_pool = {} | |
default_keepalive_pool.idle_timeout = | |
core.config_util.parse_time_unit(up_keepalive_conf.keepalive_timeout) | |
default_keepalive_pool.size = up_keepalive_conf.keepalive | |
default_keepalive_pool.requests = up_keepalive_conf.keepalive_requests | |
end | |
keepalive_pool = default_keepalive_pool | |
end | |
local idle_timeout = keepalive_pool.idle_timeout | |
local size = keepalive_pool.size | |
local requests = keepalive_pool.requests | |
core.table.clear(pool_opt) | |
pool_opt.pool_size = size | |
local scheme = up_conf.scheme | |
-- other TLS schemes don't use http balancer keepalive | |
if (scheme == "https" or scheme == "grpcs") then | |
local pool = server.host .. "#" .. server.port | |
local sni = ctx.var.upstream_host | |
pool = pool .. "#" .. sni | |
if up_conf.tls and up_conf.tls.client_cert then | |
pool = pool .. "#" .. up_conf.tls.client_cert | |
end | |
pool_opt.pool = pool | |
end | |
local ok, err = balancer.set_current_peer(server.host, server.port, | |
pool_opt) | |
if not ok then | |
return ok, err | |
end | |
return balancer.enable_keepalive(idle_timeout, requests) | |
end | |
return balancer.set_current_peer(server.host, server.port) |
if enable_keepalive
, would add pool_opt
as the third argument to balancer.set_current_peer
.
Do we fix the call to set_current_peer
here and in balancer.lua
, pass pool_opt
even if there is disable enable_keepalive
, otherwise it will all become non-persistent connection.
Description
Fixes # (issue)
Checklist