coder2z commented on code in PR #12261:
URL: https://github.com/apache/apisix/pull/12261#discussion_r2622910791
##########
apisix/balancer.lua:
##########
@@ -196,11 +196,21 @@ local function pick_server(route, ctx)
local nodes_count = #up_conf.nodes
if nodes_count == 1 then
- local node = up_conf.nodes[1]
- ctx.balancer_ip = node.host
- ctx.balancer_port = node.port
- node.upstream_host = parse_server_for_upstream_host(node,
ctx.upstream_scheme)
- return node
+ -- For least_conn balancer, we still need to use the balancer even
with single node
Review Comment:
The previous logic was that when there is only one node in the upstream, the
balancer logic is skipped directly, which is fine in the case of short
connections.
However, in the scenario of long connections, we now store the connection
count of the nodes; skipping the balancer would prevent this storage.
If we don't do this: when the number of nodes in the upstream changes from 1
to 2, the connection count of the previous node will be completely lost.
--
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]