Baoyuantop commented on code in PR #12261:
URL: https://github.com/apache/apisix/pull/12261#discussion_r2916926896


##########
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 current implementation removes single-node optimization for all 
upstreams of the `least_conn` type, not just for those with 
`persistent_conn_counting: true`. This means:
   
   - Regular `least_conn` users who haven't enabled persistent counting will 
also be affected.
   
   - Single-node upstreams no longer take the fast path, instead creating a 
full balancer instance (including binary Heap), adding unnecessary overhead.
   
   - This violates the "full backward compatibility" promise made in the PR.



-- 
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]

Reply via email to