nic-6443 commented on code in PR #12261:
URL: https://github.com/apache/apisix/pull/12261#discussion_r3393122877
##########
apisix/balancer/least_conn.lua:
##########
@@ -75,14 +198,40 @@ function _M.new(up_nodes, upstream)
return nil, err
end
- info.score = info.score + info.effect_weight
- servers_heap:update(server, info)
+ if info.use_persistent_counting then
+ -- True least connection mode: update based on persistent
connection counts
+ local current_conn_count = get_server_conn_count(upstream,
server)
+ info.score = (current_conn_count + 1) / info.weight
+ servers_heap:update(server, info)
+ incr_server_conn_count(upstream, server, 1)
Review Comment:
The decrement side of this counter never runs for the stream subsystem.
`stream_route` upstreams share the same `upstream_schema` (so
`persistent_conn_counting` is accepted there), and `stream_balancer_phase` goes
through the same `apisix.balancer` -> least_conn picker, but unlike
`http_log_phase`, `stream_log_phase` in `apisix/init.lua` never calls
`server_picker.after_balance`. So with this feature enabled on a stream
upstream, every TCP/TLS connection leaks +1 into the shared dict and is never
decremented (and the dict survives reload). Long-lived connections are exactly
what this feature targets, so this needs either an `after_balance` call in
`stream_log_phase` or the feature explicitly limited to HTTP upstreams.
--
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]